Atomic replace fails on mounted file system
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zim |
Confirmed
|
Low
|
Unassigned |
Bug Description
Saving a page of a Zim (0.61) notebook to an SSHFS FUSE mount on Linux of a Windows SSH (SFTP) server fails in the method zim.fs.
os.rename(tmp, self.encodedpath)
The comment:
# On Unix, for rename() if dest already exists it is replaced in an
# atomic operation. And other processes reading our file will not
# block moving it :)
seems not to hold true in this case.
A straightforward patch is to replace said line with:
try:
os.rename(tmp, self.encodedpath)
except OSError:
if os.path.
os.
os.rename(tmp, self.encodedpath)
This is not a particularly robust solution because the exception raised is rather broad (OSError) and because further exceptions raised are not handled in this code. Finer-grained IO exception classes and a cross-platform atomic file moving function os.replace() are only available in Python 3.3+. See: http://
description: | updated |
Probably should add a (hidden) config option to disable replace on such file systems.