Show More
@@ -40,41 +40,43 b' def active(func):' | |||||
40 | return _active |
|
40 | return _active | |
41 |
|
41 | |||
42 |
|
42 | |||
43 |
UNDO_BACKUP = b' |
|
43 | UNDO_BACKUP = b'%s.backupfiles' | |
44 |
|
44 | |||
45 | UNDO_FILES_MAY_NEED_CLEANUP = [ |
|
45 | UNDO_FILES_MAY_NEED_CLEANUP = [ | |
46 |
(b'plain', b' |
|
46 | (b'plain', b'%s.desc'), | |
47 | # Always delete undo last to make sure we detect that a clean up is needed if |
|
47 | # Always delete undo last to make sure we detect that a clean up is needed if | |
48 | # the process is interrupted. |
|
48 | # the process is interrupted. | |
49 |
(b'store', b' |
|
49 | (b'store', b'%s'), | |
50 | ] |
|
50 | ] | |
51 |
|
51 | |||
52 |
|
52 | |||
53 | def cleanup_undo_files(report, vfsmap): |
|
53 | def cleanup_undo_files(report, vfsmap, undo_prefix=b'undo'): | |
54 | """remove "undo" files used by the rollback logic |
|
54 | """remove "undo" files used by the rollback logic | |
55 |
|
55 | |||
56 | This is useful to prevent rollback running in situation were it does not |
|
56 | This is useful to prevent rollback running in situation were it does not | |
57 | make sense. For example after a strip. |
|
57 | make sense. For example after a strip. | |
58 | """ |
|
58 | """ | |
|
59 | backup_listing = UNDO_BACKUP % undo_prefix | |||
|
60 | ||||
59 | backup_entries = [] |
|
61 | backup_entries = [] | |
60 | undo_files = [] |
|
62 | undo_files = [] | |
61 | svfs = vfsmap[b'store'] |
|
63 | svfs = vfsmap[b'store'] | |
62 | try: |
|
64 | try: | |
63 |
with svfs( |
|
65 | with svfs(backup_listing) as f: | |
64 | backup_entries = read_backup_files(report, f) |
|
66 | backup_entries = read_backup_files(report, f) | |
65 | except OSError as e: |
|
67 | except OSError as e: | |
66 | if e.errno != errno.ENOENT: |
|
68 | if e.errno != errno.ENOENT: | |
67 | msg = _(b'could not read %s: %s\n') |
|
69 | msg = _(b'could not read %s: %s\n') | |
68 |
msg %= (svfs.join( |
|
70 | msg %= (svfs.join(backup_listing), stringutil.forcebytestr(e)) | |
69 | report(msg) |
|
71 | report(msg) | |
70 |
|
72 | |||
71 | for location, f, backup_path, c in backup_entries: |
|
73 | for location, f, backup_path, c in backup_entries: | |
72 | if location in vfsmap and backup_path: |
|
74 | if location in vfsmap and backup_path: | |
73 | undo_files.append((vfsmap[location], backup_path)) |
|
75 | undo_files.append((vfsmap[location], backup_path)) | |
74 |
|
76 | |||
75 |
undo_files.append((svfs, |
|
77 | undo_files.append((svfs, backup_listing)) | |
76 | for location, undo_path in UNDO_FILES_MAY_NEED_CLEANUP: |
|
78 | for location, undo_path in UNDO_FILES_MAY_NEED_CLEANUP: | |
77 | undo_files.append((vfsmap[location], undo_path)) |
|
79 | undo_files.append((vfsmap[location], undo_path % undo_prefix)) | |
78 | for undovfs, undofile in undo_files: |
|
80 | for undovfs, undofile in undo_files: | |
79 | try: |
|
81 | try: | |
80 | undovfs.unlink(undofile) |
|
82 | undovfs.unlink(undofile) |
General Comments 0
You need to be logged in to leave comments.
Login now