##// 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 46 backupfiles = []
47 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 51 vfs = vfsmap[l]
49 if f and b:
50 filepath = vfs.join(f)
51 backuppath = vfs.join(b)
52 try:
53 util.copyfile(backuppath, filepath)
54 backupfiles.append(b)
55 except IOError:
56 report(_("failed to recover %s\n") % f)
52 try:
53 if f and b:
54 filepath = vfs.join(f)
55 backuppath = vfs.join(b)
56 try:
57 util.copyfile(backuppath, filepath)
58 backupfiles.append(b)
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 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 72 opener.unlink(journal)
67 73 backuppath = "%s.backupfiles" % journal
68 74 if opener.exists(backuppath):
69 75 opener.unlink(backuppath)
70 for f in backupfiles:
71 if opener.exists(f):
72 opener.unlink(f)
76 try:
77 for f in backupfiles:
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 84 class transaction(object):
75 85 def __init__(self, report, opener, vfsmap, journal, after=None,
@@ -365,10 +375,21 b' class transaction(object):'
365 375 self.file.close()
366 376 self._backupsfile.close()
367 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 383 vfs = self._vfsmap[l]
370 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 393 self.entries = []
373 394 if self.after:
374 395 self.after()
@@ -376,10 +397,21 b' class transaction(object):'
376 397 self.opener.unlink(self.journal)
377 398 if self.opener.isfile(self._backupjournal):
378 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 405 vfs = self._vfsmap[l]
381 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 415 self._backupentries = []
384 416 self.journal = None
385 417 # run post close action
General Comments 0
You need to be logged in to leave comments. Login now