##// END OF EJS Templates
transaction: support cache file in backupentries...
Pierre-Yves David -
r23312:006e9ef0 default
parent child Browse files
Show More
@@ -45,31 +45,41 b' def _playback(journal, report, opener, v'
45
45
46 backupfiles = []
46 backupfiles = []
47 for l, f, b, c in backupentries:
47 for l, f, b, c in backupentries:
48 if l not in vfsmap and c:
49 report("couldn't handle %s: unknown cache location %s\n"
50 % (b, l))
48 vfs = vfsmap[l]
51 vfs = vfsmap[l]
49 if f and b:
52 try:
50 filepath = vfs.join(f)
53 if f and b:
51 backuppath = vfs.join(b)
54 filepath = vfs.join(f)
52 try:
55 backuppath = vfs.join(b)
53 util.copyfile(backuppath, filepath)
56 try:
54 backupfiles.append(b)
57 util.copyfile(backuppath, filepath)
55 except IOError:
58 backupfiles.append(b)
56 report(_("failed to recover %s\n") % f)
59 except IOError:
60 report(_("failed to recover %s\n") % f)
61 else:
62 target = f or b
63 try:
64 vfs.unlink(target)
65 except (IOError, OSError), inst:
66 if inst.errno != errno.ENOENT:
67 raise
68 except (IOError, OSError, util.Abort), inst:
69 if not c:
57 raise
70 raise
58 else:
59 target = f or b
60 try:
61 vfs.unlink(target)
62 except (IOError, OSError), inst:
63 if inst.errno != errno.ENOENT:
64 raise
65
71
66 opener.unlink(journal)
72 opener.unlink(journal)
67 backuppath = "%s.backupfiles" % journal
73 backuppath = "%s.backupfiles" % journal
68 if opener.exists(backuppath):
74 if opener.exists(backuppath):
69 opener.unlink(backuppath)
75 opener.unlink(backuppath)
70 for f in backupfiles:
76 try:
71 if opener.exists(f):
77 for f in backupfiles:
72 opener.unlink(f)
78 if opener.exists(f):
79 opener.unlink(f)
80 except (IOError, OSError, util.Abort), inst:
81 # only pure backup file remains, it is sage to ignore any error
82 pass
73
83
74 class transaction(object):
84 class transaction(object):
75 def __init__(self, report, opener, vfsmap, journal, after=None,
85 def __init__(self, report, opener, vfsmap, journal, after=None,
@@ -365,10 +375,21 b' class transaction(object):'
365 self.file.close()
375 self.file.close()
366 self._backupsfile.close()
376 self._backupsfile.close()
367 # cleanup temporary files
377 # cleanup temporary files
368 for l, f, b, _c in self._backupentries:
378 for l, f, b, c in self._backupentries:
379 if l not in self._vfsmap and c:
380 self.report("couldn't remote %s: unknown cache location %s\n"
381 % (b, l))
382 continue
369 vfs = self._vfsmap[l]
383 vfs = self._vfsmap[l]
370 if not f and b and vfs.exists(b):
384 if not f and b and vfs.exists(b):
371 vfs.unlink(b)
385 try:
386 vfs.unlink(b)
387 except (IOError, OSError, util.Abort), inst:
388 if not c:
389 raise
390 # Abort may be raise by read only opener
391 self.report("couldn't remote %s: %s\n"
392 % (vfs.join(b), inst))
372 self.entries = []
393 self.entries = []
373 if self.after:
394 if self.after:
374 self.after()
395 self.after()
@@ -376,10 +397,21 b' class transaction(object):'
376 self.opener.unlink(self.journal)
397 self.opener.unlink(self.journal)
377 if self.opener.isfile(self._backupjournal):
398 if self.opener.isfile(self._backupjournal):
378 self.opener.unlink(self._backupjournal)
399 self.opener.unlink(self._backupjournal)
379 for _l, _f, b, _c in self._backupentries:
400 for _l, _f, b, c in self._backupentries:
401 if l not in self._vfsmap and c:
402 self.report("couldn't remote %s: unknown cache location"
403 "%s\n" % (b, l))
404 continue
380 vfs = self._vfsmap[l]
405 vfs = self._vfsmap[l]
381 if b and vfs.exists(b):
406 if b and vfs.exists(b):
382 vfs.unlink(b)
407 try:
408 vfs.unlink(b)
409 except (IOError, OSError, util.Abort), inst:
410 if not c:
411 raise
412 # Abort may be raise by read only opener
413 self.report("couldn't remote %s: %s\n"
414 % (vfs.join(b), inst))
383 self._backupentries = []
415 self._backupentries = []
384 self.journal = None
416 self.journal = None
385 # run post close action
417 # run post close action
General Comments 0
You need to be logged in to leave comments. Login now