Show More
@@ -737,6 +737,32 b' BAD_VERSION_MSG = _(' | |||||
737 | ) |
|
737 | ) | |
738 |
|
738 | |||
739 |
|
739 | |||
|
740 | def read_backup_files(report, fp): | |||
|
741 | """parse an (already open) backup file an return contained backup entries | |||
|
742 | ||||
|
743 | entries are in the form: (location, file, backupfile, xxx) | |||
|
744 | ||||
|
745 | :location: the vfs identifier (vfsmap's key) | |||
|
746 | :file: original file path (in the vfs) | |||
|
747 | :backupfile: path of the backup (in the vfs) | |||
|
748 | :cache: a boolean currently always set to False | |||
|
749 | """ | |||
|
750 | lines = fp.readlines() | |||
|
751 | backupentries = [] | |||
|
752 | if lines: | |||
|
753 | ver = lines[0][:-1] | |||
|
754 | if ver != (b'%d' % version): | |||
|
755 | report(BAD_VERSION_MSG) | |||
|
756 | else: | |||
|
757 | for line in lines[1:]: | |||
|
758 | if line: | |||
|
759 | # Shave off the trailing newline | |||
|
760 | line = line[:-1] | |||
|
761 | l, f, b, c = line.split(b'\0') | |||
|
762 | backupentries.append((l, f, b, bool(c))) | |||
|
763 | return backupentries | |||
|
764 | ||||
|
765 | ||||
740 | def rollback( |
|
766 | def rollback( | |
741 | opener, |
|
767 | opener, | |
742 | vfsmap, |
|
768 | vfsmap, | |
@@ -776,19 +802,8 b' def rollback(' | |||||
776 |
|
802 | |||
777 | backupjournal = b"%s.backupfiles" % file |
|
803 | backupjournal = b"%s.backupfiles" % file | |
778 | if opener.exists(backupjournal): |
|
804 | if opener.exists(backupjournal): | |
779 |
|
|
805 | with opener.open(backupjournal) as fp: | |
780 | lines = fp.readlines() |
|
806 | backupentries = read_backup_files(report, fp) | |
781 | if lines: |
|
|||
782 | ver = lines[0][:-1] |
|
|||
783 | if ver != (b'%d' % version): |
|
|||
784 | report(BAD_VERSION_MSG) |
|
|||
785 | else: |
|
|||
786 | for line in lines[1:]: |
|
|||
787 | if line: |
|
|||
788 | # Shave off the trailing newline |
|
|||
789 | line = line[:-1] |
|
|||
790 | l, f, b, c = line.split(b'\0') |
|
|||
791 | backupentries.append((l, f, b, bool(c))) |
|
|||
792 | if skip_journal_pattern is not None: |
|
807 | if skip_journal_pattern is not None: | |
793 | keep = lambda x: not skip_journal_pattern.match(x[1]) |
|
808 | keep = lambda x: not skip_journal_pattern.match(x[1]) | |
794 | backupentries = [x for x in backupentries if keep(x)] |
|
809 | backupentries = [x for x in backupentries if keep(x)] |
General Comments 0
You need to be logged in to leave comments.
Login now