@@ -1868,6 +1868,8 @@ def valid_archive(obj):
18681868 manifest .archives [name ] = (chunk_id , archive .time )
18691869 pi .finish ()
18701870 logger .info ('Manifest rebuild complete.' )
1871+ if not self .repair :
1872+ logger .warning ('The rebuilt manifest will only be committed when using --repair!' )
18711873 return manifest
18721874
18731875 def rebuild_refcounts (self , archive = None , first = 0 , last = 0 , sort_by = '' , glob = None ):
@@ -1918,7 +1920,11 @@ def replacement_chunk(size):
19181920 chunks_healthy = item .chunks_healthy if has_chunks_healthy else chunks_current
19191921 if has_chunks_healthy and len (chunks_current ) != len (chunks_healthy ):
19201922 # should never happen, but there was issue #3218.
1921- logger .warning (f'{ archive_name } : { item .path } : Invalid chunks_healthy metadata removed!' )
1923+ if self .repair :
1924+ msg = 'Invalid chunks_healthy metadata removed!'
1925+ else :
1926+ msg = 'Invalid chunks_healthy metadata would be removed with --repair!'
1927+ logger .warning (f'{ archive_name } : { item .path } : { msg } ' )
19221928 del item .chunks_healthy
19231929 has_chunks_healthy = False
19241930 chunks_healthy = chunks_current
@@ -1927,9 +1933,12 @@ def replacement_chunk(size):
19271933 if chunk_id not in self .chunks :
19281934 # a chunk of the healthy list is missing
19291935 if chunk_current == chunk_healthy :
1930- logger .error ('{}: {}: New missing file chunk detected (Byte {}-{}, Chunk {}). '
1931- 'Replacing with all-zero chunk.' .format (
1932- archive_name , item .path , offset , offset + size , bin_to_hex (chunk_id )))
1936+ if self .repair :
1937+ msg = 'Replacing with all-zero chunk.'
1938+ else :
1939+ msg = 'Could replace it with all-zero chunk with --repair.'
1940+ logger .error (f'{ archive_name } : { item .path } : New missing file chunk detected '
1941+ f'(Byte { offset } -{ offset + size } , Chunk { bin_to_hex (chunk_id )} ). { msg } ' )
19331942 self .error_found = chunks_replaced = True
19341943 chunk_id , size , csize , cdata = replacement_chunk (size )
19351944 add_reference (chunk_id , size , csize , cdata )
@@ -1941,9 +1950,12 @@ def replacement_chunk(size):
19411950 if chunk_id in self .chunks :
19421951 add_reference (chunk_id , size , csize )
19431952 else :
1944- logger .warning ('{}: {}: Missing all-zero replacement chunk detected (Byte {}-{}, Chunk {}). '
1945- 'Generating new replacement chunk.' .format (
1946- archive_name , item .path , offset , offset + size , bin_to_hex (chunk_id )))
1953+ if self .repair :
1954+ msg = 'Generating new replacement chunk.'
1955+ else :
1956+ msg = 'Would generate new replacement chunk with --repair.'
1957+ logger .warning (f'{ archive_name } : { item .path } : Missing all-zero replacement chunk detected '
1958+ f'(Byte { offset } -{ offset + size } , Chunk { bin_to_hex (chunk_id )} ). { msg } ' )
19471959 self .error_found = chunks_replaced = True
19481960 chunk_id , size , csize , cdata = replacement_chunk (size )
19491961 add_reference (chunk_id , size , csize , cdata )
@@ -1952,8 +1964,12 @@ def replacement_chunk(size):
19521964 # normal case, all fine.
19531965 add_reference (chunk_id , size , csize )
19541966 else :
1955- logger .info ('{}: {}: Healed previously missing file chunk! (Byte {}-{}, Chunk {}).' .format (
1956- archive_name , item .path , offset , offset + size , bin_to_hex (chunk_id )))
1967+ if self .repair :
1968+ msg = 'Healed previously missing file chunk!'
1969+ else :
1970+ msg = 'Missing file chunk could be healed with --repair!'
1971+ logger .info (f'{ archive_name } : { item .path } : { msg } '
1972+ f'(Byte { offset } -{ offset + size } , Chunk { bin_to_hex (chunk_id )} )' )
19571973 add_reference (chunk_id , size , csize )
19581974 mark_as_possibly_superseded (chunk_current [0 ]) # maybe orphaned the all-zero replacement chunk
19591975 chunk_list .append ([chunk_id , size , csize ]) # list-typed element as chunks_healthy is list-of-lists
@@ -1962,7 +1978,11 @@ def replacement_chunk(size):
19621978 # if this is first repair, remember the correct chunk IDs, so we can maybe heal the file later
19631979 item .chunks_healthy = item .chunks
19641980 if has_chunks_healthy and chunk_list == chunks_healthy :
1965- logger .info (f'{ archive_name } : { item .path } : Completely healed previously damaged file!' )
1981+ if self .repair :
1982+ msg = 'Completely healed previously damaged file!'
1983+ else :
1984+ msg = 'Could completely heal damaged file with --repair!'
1985+ logger .info (f'{ archive_name } : { item .path } : { msg } ' )
19661986 del item .chunks_healthy
19671987 item .chunks = chunk_list
19681988 if 'size' in item :
@@ -2095,7 +2115,11 @@ def valid_item(obj):
20952115 # when upgrading to borg 1.2.5, users are expected to TAM-authenticate all archives they
20962116 # trust, so there shouldn't be any without TAM.
20972117 logger .error ('Archive TAM authentication issue for archive %s: %s' , info .name , integrity_error )
2098- logger .error ('This archive will be *removed* from the manifest! It will be deleted.' )
2118+ if self .repair :
2119+ msg = 'This archive will be *removed* from the manifest! It will be deleted.'
2120+ else :
2121+ msg = 'This archive would be *removed* / *deleted* when using --repair!'
2122+ logger .error (msg )
20992123 self .error_found = True
21002124 del self .manifest .archives [info .name ]
21012125 continue
0 commit comments