Skip to content

Commit

Permalink
core/local: Don't retry moving locked docs (#2018)
Browse files Browse the repository at this point in the history
On Windows, files and folders can be locked by software. These locks
result in `EPERM`, `EBUSY` or `EACCES` errors when trying to modify or
move the documents (and sometimes their parent folders).
For example, Anti-Virus software can block a folder for up to a minute
and for this reason `graceful-fs`, the drop-in replacement for Node's
`fs` module used by our own dependency `fs-extra` adds a retry
mechanism to the `rename` method in case the returned error is `EPERM`
or `EACCES`.
See https://github.com/isaacs/node-graceful-fs/blob/1139b6f1e255aeddbf2abd1380a359792d8ea91a/polyfills.js#L83

Now that we're blocking the synchronization on local filesystem
permission errors, this comes at odds with our own retry mechanism and
delays the result of our retries for a full minute during which we
display a "synchronizing" state to the user.
We probably don't need the retry mechanism from `graceful-fs` anymore
so we use the `fs` module directly when making `rename` calls.

If this change proves to be more inconvenient than useful, we can
always revisit this decision.
  • Loading branch information
taratatach authored Jan 18, 2021
1 parent fea8147 commit 49f3c4a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/local/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

const async = require('async')
const autoBind = require('auto-bind')
const fs = require('fs').promises
const fse = require('fs-extra')
const path = require('path')
const trash = require('trash')
Expand Down Expand Up @@ -422,7 +423,7 @@ class Local /*:: implements Reader, Writer */ {
}
}

await fse.rename(oldPath, newPath)
await fs.rename(oldPath, newPath)
await this.updateMetadataAsync(doc)
metadata.updateLocal(doc)
}
Expand Down

0 comments on commit 49f3c4a

Please sign in to comment.