Browse Source

recreate: if single archive is not processed, exit 2

Marian Beermann 8 năm trước cách đây
mục cha
commit
8ad309ae2a
2 tập tin đã thay đổi với 7 bổ sung4 xóa
  1. 2 2
      src/borg/archive.py
  2. 5 2
      src/borg/archiver.py

+ 2 - 2
src/borg/archive.py

@@ -1612,11 +1612,11 @@ class ArchiveRecreater:
         if self.exclude_if_present or self.exclude_caches:
         if self.exclude_if_present or self.exclude_caches:
             self.matcher_add_tagged_dirs(archive)
             self.matcher_add_tagged_dirs(archive)
         if self.matcher.empty() and not self.recompress and not target.recreate_rechunkify and comment is None:
         if self.matcher.empty() and not self.recompress and not target.recreate_rechunkify and comment is None:
-            logger.info("Skipping archive %s, nothing to do", archive_name)
-            return
+            return False
         self.process_items(archive, target)
         self.process_items(archive, target)
         replace_original = target_name is None
         replace_original = target_name is None
         self.save(archive, target, comment, replace_original=replace_original)
         self.save(archive, target, comment, replace_original=replace_original)
+        return True
 
 
     def process_items(self, archive, target):
     def process_items(self, archive, target):
         matcher = self.matcher
         matcher = self.matcher

+ 5 - 2
src/borg/archiver.py

@@ -1598,7 +1598,9 @@ class Archiver:
             if recreater.is_temporary_archive(name):
             if recreater.is_temporary_archive(name):
                 self.print_error('Refusing to work on temporary archive of prior recreate: %s', name)
                 self.print_error('Refusing to work on temporary archive of prior recreate: %s', name)
                 return self.exit_code
                 return self.exit_code
-            recreater.recreate(name, args.comment, target)
+            if not recreater.recreate(name, args.comment, target):
+                self.print_error('Nothing to do. Archive was not processed.\n'
+                                 'Specify at least one pattern, PATH, --comment, re-compression or re-chunking option.')
         else:
         else:
             if args.target is not None:
             if args.target is not None:
                 self.print_error('--target: Need to specify single archive')
                 self.print_error('--target: Need to specify single archive')
@@ -1608,7 +1610,8 @@ class Archiver:
                 if recreater.is_temporary_archive(name):
                 if recreater.is_temporary_archive(name):
                     continue
                     continue
                 print('Processing', name)
                 print('Processing', name)
-                recreater.recreate(name, args.comment)
+                if not recreater.recreate(name, args.comment):
+                    logger.info('Skipped archive %s: Nothing to do. Archive was not processed.', name)
         if not args.dry_run:
         if not args.dry_run:
             manifest.write()
             manifest.write()
             repository.commit()
             repository.commit()