Comments
Patch
@@ -186,11 +186,11 @@ class transaction(object):
# add enough data to the journal to do the truncate
self.file.write("%s\0%d\n" % (file, offset))
self.file.flush()
@active
- def addbackup(self, file, hardlink=True, vfs=None):
+ def addbackup(self, file, hardlink=True, location=''):
"""Adds a backup of the file to the transaction
Calling addbackup() creates a hardlink backup of the specified file
that is used to recover the file in the event of the transaction
aborting.
@@ -203,23 +203,21 @@ class transaction(object):
raise RuntimeError(msg)
if file in self.map or file in self._backupmap:
return
dirname, filename = os.path.split(file)
-
backupfilename = "%s.backup.%s" % (self.journal, filename)
backupfile = os.path.join(dirname, backupfilename)
- if vfs is None:
- vfs = self.opener
+ vfs = self._vfsmap[location]
if vfs.exists(file):
filepath = vfs.join(file)
backuppath = vfs.join(backupfile)
util.copyfiles(filepath, backuppath, hardlink=hardlink)
else:
backupfile = ''
- self._addbackupentry(('', file, backupfile, False))
+ self._addbackupentry((location, file, backupfile, False))
def _addbackupentry(self, entry):
"""register a new backup entry and write it to disk"""
self._backupentries.append(entry)
self._backupmap[file] = len(self._backupentries) - 1