Saving a page of a Zim (0.61) notebook to an SSHFS FUSE mount on Linux of a Windows SSH (SFTP) server, the method zim.fs.UnixFile#_on_write fails due an OSError exception in:
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.exists(self.encodedpath):
os.unlink(self.encodedpath)
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://bugs.python.org/issue8828
Saving a page of a Zim (0.61) notebook to an SSHFS FUSE mount on Linux of a Windows SSH (SFTP) server, the method zim.fs. UnixFile# _on_write fails due an OSError exception in:
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: exists( self.encodedpat h): unlink( self.encodedpat h)
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:// bugs.python. org/issue8828