-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DRIVERS-2807 Update GridFS spec to add delete_by_name
and rename_by_name
#1702
Conversation
renameByName
and deleteByName
renameByName
and deleteByName
delete_by_name
and rename_by_name
delete_by_name
and rename_by_namedelete_by_name
and rename_by_name
source/gridfs/gridfs-spec.md
Outdated
**Implementation details:** | ||
|
||
Drivers MUST first find the `_id` field of all files collection documents with the given filename. Drivers MUST then | ||
delete all chunks with `files_id` in the found ids that was just deleted. Drivers MUST then delete all files collection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't we want to delete the files documents first and then the chunks? Doing the opposite increases the chance of reading a phantom corrupt file. This is the same reason we always upload the chunks before saving the files document.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct. Files should be deleted before chunks to ensure there is no partial files. But if the operation that deletes chunks fails, then there is orphan chunks.
Spec updated.
c1ce40a
to
841a729
Compare
source/gridfs/gridfs-spec.md
Outdated
|
||
Drivers MUST first find the `_id` field of all files collection documents with the given filename. Drivers MUST then | ||
delete all files collection documents with the found ids. Drivers MUST then delete all chunks with `files_id` in the | ||
found ids that was just deleted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ids that was just deleted.
-> ids that were just deleted.
Or use client.bulk_write() to delete both in one command :). We can leave that as a future optimization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or use client.bulk_write() to delete both in one command :). We can leave that as a future optimization.
This would require server version 8.0 with the new client bulk write API to perform operations on both collections.
delete_by_name
and rename_by_name
delete_by_name
and rename_by_name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after the small grammar fix.
To rename all revisions of a stored file with the specified filename, drivers SHOULD provide the method | ||
`rename_by_name`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing I did not think about is if there is already a newer file with the new filename, then it will stay the last revision for this filename.
We can't change the date of the renamed files, as that would change the order of the revisions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct that seems like expected behavior to me.
Fix DRIVERS-2808 and DRIVERS-2807
Please complete the following before merging:
GridFS\Bucket::deleteByName(filename)
andrenameByName(filename, newFilename)
mongo-php-library#1504