mirror of
https://github.com/borgbackup/borg.git
synced 2025-01-03 05:35:58 +00:00
check: only write to repo if --repair is given
old borg just didn't commit the transaction and thus caused a transaction rollback if not in repair mode. we can't do that anymore, thus we must avoid modifying the repo if not in repair mode.
This commit is contained in:
parent
ef7dd76da1
commit
8412168555
1 changed files with 21 additions and 10 deletions
|
@ -2025,7 +2025,11 @@ def valid_item(obj):
|
|||
if archive_id not in self.chunks:
|
||||
logger.error("Archive metadata block %s is missing!", bin_to_hex(archive_id))
|
||||
self.error_found = True
|
||||
self.manifest.archives.delete(info.name)
|
||||
if self.repair:
|
||||
logger.error(f"Deleting broken archive {info.name}.")
|
||||
self.manifest.archives.delete(info.name)
|
||||
else:
|
||||
logger.error(f"Would delete broken archive {info.name}.")
|
||||
continue
|
||||
cdata = self.repository.get(archive_id)
|
||||
try:
|
||||
|
@ -2033,7 +2037,11 @@ def valid_item(obj):
|
|||
except IntegrityError as integrity_error:
|
||||
logger.error("Archive metadata block %s is corrupted: %s", bin_to_hex(archive_id), integrity_error)
|
||||
self.error_found = True
|
||||
self.manifest.archives.delete(info.name)
|
||||
if self.repair:
|
||||
logger.error(f"Deleting broken archive {info.name}.")
|
||||
self.manifest.archives.delete(info.name)
|
||||
else:
|
||||
logger.error(f"Would delete broken archive {info.name}.")
|
||||
continue
|
||||
archive = self.key.unpack_archive(data)
|
||||
archive = ArchiveItem(internal_dict=archive)
|
||||
|
@ -2046,14 +2054,17 @@ def valid_item(obj):
|
|||
verify_file_chunks(info.name, item)
|
||||
items_buffer.add(item)
|
||||
items_buffer.flush(flush=True)
|
||||
archive.item_ptrs = archive_put_items(
|
||||
items_buffer.chunks, repo_objs=self.repo_objs, add_reference=add_reference
|
||||
)
|
||||
data = self.key.pack_metadata(archive.as_dict())
|
||||
new_archive_id = self.key.id_hash(data)
|
||||
cdata = self.repo_objs.format(new_archive_id, {}, data, ro_type=ROBJ_ARCHIVE_META)
|
||||
add_reference(new_archive_id, len(data), cdata)
|
||||
self.manifest.archives.create(info.name, new_archive_id, info.ts, overwrite=True)
|
||||
if self.repair:
|
||||
archive.item_ptrs = archive_put_items(
|
||||
items_buffer.chunks, repo_objs=self.repo_objs, add_reference=add_reference
|
||||
)
|
||||
data = self.key.pack_metadata(archive.as_dict())
|
||||
new_archive_id = self.key.id_hash(data)
|
||||
logger.debug(f"archive id old: {bin_to_hex(archive_id)}")
|
||||
logger.debug(f"archive id new: {bin_to_hex(new_archive_id)}")
|
||||
cdata = self.repo_objs.format(new_archive_id, {}, data, ro_type=ROBJ_ARCHIVE_META)
|
||||
add_reference(new_archive_id, len(data), cdata)
|
||||
self.manifest.archives.create(info.name, new_archive_id, info.ts, overwrite=True)
|
||||
pi.finish()
|
||||
|
||||
def finish(self):
|
||||
|
|
Loading…
Reference in a new issue