Merge pull request #7213 from ThomasWaldmann/remove-save-space

remove --save-space
This commit is contained in:
TW 2022-12-17 17:17:10 +01:00 committed by GitHub
commit a3614b5a3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 13 additions and 42 deletions

View File

@ -1691,16 +1691,13 @@ class ArchiveChecker:
self.error_found = False self.error_found = False
self.possibly_superseded = set() self.possibly_superseded = set()
def check( def check(self, repository, repair=False, first=0, last=0, sort_by="", match=None, verify_data=False):
self, repository, repair=False, first=0, last=0, sort_by="", match=None, verify_data=False, save_space=False
):
"""Perform a set of checks on 'repository' """Perform a set of checks on 'repository'
:param repair: enable repair mode, write updated or corrected data into repository :param repair: enable repair mode, write updated or corrected data into repository
:param first/last/sort_by: only check this number of first/last archives ordered by sort_by :param first/last/sort_by: only check this number of first/last archives ordered by sort_by
:param match: only check archives matching this pattern :param match: only check archives matching this pattern
:param verify_data: integrity verification of data referenced by archives :param verify_data: integrity verification of data referenced by archives
:param save_space: Repository.commit(save_space)
""" """
logger.info("Starting archive consistency check...") logger.info("Starting archive consistency check...")
self.check_all = not any((first, last, match)) self.check_all = not any((first, last, match))
@ -1728,7 +1725,7 @@ class ArchiveChecker:
self.manifest = self.rebuild_manifest() self.manifest = self.rebuild_manifest()
self.rebuild_refcounts(match=match, first=first, last=last, sort_by=sort_by) self.rebuild_refcounts(match=match, first=first, last=last, sort_by=sort_by)
self.orphan_chunks_check() self.orphan_chunks_check()
self.finish(save_space=save_space) self.finish()
if self.error_found: if self.error_found:
logger.error("Archive consistency check complete, problems found.") logger.error("Archive consistency check complete, problems found.")
else: else:
@ -2192,12 +2189,12 @@ class ArchiveChecker:
else: else:
logger.info("Orphaned objects check skipped (needs all archives checked).") logger.info("Orphaned objects check skipped (needs all archives checked).")
def finish(self, save_space=False): def finish(self):
if self.repair: if self.repair:
logger.info("Writing Manifest.") logger.info("Writing Manifest.")
self.manifest.write() self.manifest.write()
logger.info("Committing repo.") logger.info("Committing repo.")
self.repository.commit(compact=False, save_space=save_space) self.repository.commit(compact=False)
class ArchiveRecreater: class ArchiveRecreater:

View File

@ -47,7 +47,7 @@ class CheckMixIn:
self.print_error("--repository-only is required for --max-duration support.") self.print_error("--repository-only is required for --max-duration support.")
return EXIT_ERROR return EXIT_ERROR
if not args.archives_only: if not args.archives_only:
if not repository.check(repair=args.repair, save_space=args.save_space, max_duration=args.max_duration): if not repository.check(repair=args.repair, max_duration=args.max_duration):
return EXIT_WARNING return EXIT_WARNING
if not args.repo_only and not ArchiveChecker().check( if not args.repo_only and not ArchiveChecker().check(
repository, repository,
@ -57,7 +57,6 @@ class CheckMixIn:
sort_by=args.sort_by or "ts", sort_by=args.sort_by or "ts",
match=args.match_archives, match=args.match_archives,
verify_data=args.verify_data, verify_data=args.verify_data,
save_space=args.save_space,
): ):
return EXIT_WARNING return EXIT_WARNING
return EXIT_SUCCESS return EXIT_SUCCESS
@ -168,9 +167,6 @@ class CheckMixIn:
subparser.add_argument( subparser.add_argument(
"--repair", dest="repair", action="store_true", help="attempt to repair any inconsistencies found" "--repair", dest="repair", action="store_true", help="attempt to repair any inconsistencies found"
) )
subparser.add_argument(
"--save-space", dest="save_space", action="store_true", help="work slower, but using less space"
)
subparser.add_argument( subparser.add_argument(
"--max-duration", "--max-duration",
metavar="SECONDS", metavar="SECONDS",

View File

@ -60,7 +60,7 @@ class DeleteMixIn:
def checkpoint_func(): def checkpoint_func():
manifest.write() manifest.write()
repository.commit(compact=False, save_space=args.save_space) repository.commit(compact=False)
cache.commit() cache.commit()
msg_delete = "Would delete archive: {} ({}/{})" if dry_run else "Deleting archive: {} ({}/{})" msg_delete = "Would delete archive: {} ({}/{})" if dry_run else "Deleting archive: {} ({}/{})"
@ -157,9 +157,6 @@ class DeleteMixIn:
default=0, default=0,
help="force deletion of corrupted archives, " "use ``--force --force`` in case ``--force`` does not work.", help="force deletion of corrupted archives, " "use ``--force --force`` in case ``--force`` does not work.",
) )
subparser.add_argument(
"--save-space", dest="save_space", action="store_true", help="work slower, but using less space"
)
subparser.add_argument( subparser.add_argument(
"-c", "-c",
"--checkpoint-interval", "--checkpoint-interval",

View File

@ -123,7 +123,7 @@ class PruneMixIn:
def checkpoint_func(): def checkpoint_func():
manifest.write() manifest.write()
repository.commit(compact=False, save_space=args.save_space) repository.commit(compact=False)
cache.commit() cache.commit()
list_logger = logging.getLogger("borg.output.list") list_logger = logging.getLogger("borg.output.list")
@ -289,9 +289,6 @@ class PruneMixIn:
"-y", "--keep-yearly", dest="yearly", type=int, default=0, help="number of yearly archives to keep" "-y", "--keep-yearly", dest="yearly", type=int, default=0, help="number of yearly archives to keep"
) )
define_archive_filters_group(subparser, sort_by=False, first_last=False) define_archive_filters_group(subparser, sort_by=False, first_last=False)
subparser.add_argument(
"--save-space", dest="save_space", action="store_true", help="work slower, but using less space"
)
subparser.add_argument( subparser.add_argument(
"-c", "-c",
"--checkpoint-interval", "--checkpoint-interval",

View File

@ -119,8 +119,8 @@ class UnexpectedRPCDataFormatFromServer(Error):
compatMap = { compatMap = {
"check": ("repair", "save_space"), "check": ("repair",),
"commit": ("save_space",), "commit": (),
"rollback": (), "rollback": (),
"destroy": (), "destroy": (),
"__len__": (), "__len__": (),
@ -958,7 +958,7 @@ This problem will go away as soon as the server has been upgraded to 1.0.7+.
"""actual remoting is done via self.call in the @api decorator""" """actual remoting is done via self.call in the @api decorator"""
@api(since=parse_version("1.0.0"), max_duration={"since": parse_version("1.2.0a4"), "previously": 0}) @api(since=parse_version("1.0.0"), max_duration={"since": parse_version("1.2.0a4"), "previously": 0})
def check(self, repair=False, save_space=False, max_duration=0): def check(self, repair=False, max_duration=0):
"""actual remoting is done via self.call in the @api decorator""" """actual remoting is done via self.call in the @api decorator"""
@api( @api(
@ -966,7 +966,7 @@ This problem will go away as soon as the server has been upgraded to 1.0.7+.
compact={"since": parse_version("1.2.0a0"), "previously": True, "dontcare": True}, compact={"since": parse_version("1.2.0a0"), "previously": True, "dontcare": True},
threshold={"since": parse_version("1.2.0a8"), "previously": 0.1, "dontcare": True}, threshold={"since": parse_version("1.2.0a8"), "previously": 0.1, "dontcare": True},
) )
def commit(self, save_space=False, compact=True, threshold=0.1): def commit(self, compact=True, threshold=0.1):
"""actual remoting is done via self.call in the @api decorator""" """actual remoting is done via self.call in the @api decorator"""
@api(since=parse_version("1.0.0")) @api(since=parse_version("1.0.0"))

View File

@ -505,9 +505,8 @@ class Repository:
self.lock.release() self.lock.release()
self.lock = None self.lock = None
def commit(self, save_space=False, compact=True, threshold=0.1): def commit(self, compact=True, threshold=0.1):
"""Commit transaction""" """Commit transaction"""
# save_space is not used anymore, but stays for RPC/API compatibility.
if self.transaction_doomed: if self.transaction_doomed:
exception = self.transaction_doomed exception = self.transaction_doomed
self.rollback() self.rollback()
@ -1022,7 +1021,7 @@ class Repository:
# The outcome of the DELETE has been recorded in the PUT branch already. # The outcome of the DELETE has been recorded in the PUT branch already.
self.compact[segment] += header_size(tag) + size self.compact[segment] += header_size(tag) + size
def check(self, repair=False, save_space=False, max_duration=0): def check(self, repair=False, max_duration=0):
"""Check repository consistency """Check repository consistency
This method verifies all segment checksums and makes sure This method verifies all segment checksums and makes sure

View File

@ -161,21 +161,6 @@ class ArchiverTestCase(ArchiverTestCaseBase):
assert re.search(r"Keeping archive \(rule: monthly #1\):\s+september30", output) assert re.search(r"Keeping archive \(rule: monthly #1\):\s+september30", output)
self.assert_not_in("original_archive", output) self.assert_not_in("original_archive", output)
def test_prune_repository_save_space(self):
self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
self.cmd(f"--repo={self.repository_location}", "create", "test1", src_dir)
self.cmd(f"--repo={self.repository_location}", "create", "test2", src_dir)
output = self.cmd(f"--repo={self.repository_location}", "prune", "--list", "--dry-run", "--keep-daily=1")
assert re.search(r"Keeping archive \(rule: daily #1\):\s+test2", output)
assert re.search(r"Would prune:\s+test1", output)
output = self.cmd(f"--repo={self.repository_location}", "rlist")
self.assert_in("test1", output)
self.assert_in("test2", output)
self.cmd(f"--repo={self.repository_location}", "prune", "--save-space", "--keep-daily=1")
output = self.cmd(f"--repo={self.repository_location}", "rlist")
self.assert_not_in("test1", output)
self.assert_in("test2", output)
def test_prune_repository_prefix(self): def test_prune_repository_prefix(self):
self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION) self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
self.cmd(f"--repo={self.repository_location}", "create", "foo-2015-08-12-10:00", src_dir) self.cmd(f"--repo={self.repository_location}", "create", "foo-2015-08-12-10:00", src_dir)