syncObject: delete 'coms-id' tag on new file if id already in use #289
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When syncing, if a object not currently in COMS has a
coms-id
S3 tag with a value already in use inside COMS, delete the S3 tag and re-generate a new object ID before adding it to COMS.This resolves a bug with renaming a file and syncing the folder it's in; COMS will mark the file as soft-deleted but fail to pick up the name change (thus resulting in a de-sync between COMS/S3). In BCBox, it will appear as if renaming the file and syncing it removes it.
https://apps.nrs.gov.bc.ca/int/jira/browse/SHOWCASE-3782
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist
Further comments
Motivation
Please see Jira ticket for a more detailed explanation
S3 doesn't support file renaming; any attempt to do so (e.g. in GeoDrive or any external S3 tool/browser) is actually 2 operations:
In (1), the new copy will include the same S3 tags and metadata as the original.
In (2), if the bucket has file versioning enabled, then it is a soft deletion. For COMS, this means that the old file still fully exists in its database.
When syncing, COMS will detect (2) as a new file and will try to add it to COMS, using the same
coms-id
it sees in its S3 tags. Attempting to re-use the same id will result in database errors, since it's the primary key for a COMS object.Consequences on file version history
Unfortunately, the "new" file with the updated name will lose its version history, since it's held by the "old" copy. However, since it's only soft-deleted in a versioned bucket, the file history technically still exists; it's just that it's not associated with the renamed "active" file.
While it's probably technically possible (on some level) to have COMS "link" the renamed file to the old soft-deleted one, such that you'd get one continuous file history, this is probably overly complex for limited gain - the 2 files are completely separate entities in S3, so you'd have to hack together some novel non-S3 concept to have them linked.