GridFS and versioning files


In docs I found this statement:

Do not use GridFS if you need to update the content of the entire file atomically. As an alternative you can store multiple versions of each file and specify the current version of the file in the metadata. You can update the metadata field that indicates “latest” status in an atomic update after uploading the new version of the file, and later remove previous versions if needed.

So I understand that I have to set the new file to latest after uploading it and next remove previous version that had also version latest.

Here I have concern that in such scenario there will be short period of time where I will have 2 latest versions:

  1. Set the uploaded file to latest version.
  2. Previously uploaded file has still latest version.
  3. Delete previous version file.

So in step 2 there are 2 latest versions.

Or you mean that in one atomic transaction I have to update uploaded file version and delete previous file?
I understood the in mongo atomicity is only on single document level always.