@@ -719,9 +719,9 @@ def extract_helper(self, item, path, hlm, *, dry_run=False):
719719 # In this case, we *want* to extract twice, because there is no other way.
720720 pass
721721
722- def compare_and_extract_chunks (self , item , fs_path , * , pi = None , sparse = False ):
722+ def compare_and_extract_chunks (self , item , fs_path , * , st , pi = None ):
723723 """Compare file chunks and patch if needed. Returns True if patching succeeded."""
724- if not os . path . exists ( fs_path ) :
724+ if st is None :
725725 return False
726726 try :
727727 # First pass: Build fs chunks list
@@ -755,12 +755,8 @@ def compare_and_extract_chunks(self, item, fs_path, *, pi=None, sparse=False):
755755 else :
756756 chunk_data = next (chunk_data_iter )
757757
758- with backup_io ("seek" ):
759- fs_file .seek (fs_file .tell ())
760-
761758 with backup_io ("write" ):
762- data = b"\0 " * len (chunk_data ) if sparse and not chunk_data .strip (b"\0 " ) else chunk_data
763- fs_file .write (data )
759+ fs_file .write (chunk_data )
764760 if pi :
765761 pi .show (increase = len (chunk_data ), info = [remove_surrogates (item .path )])
766762
@@ -863,12 +859,14 @@ def same_item(item, st):
863859 return # done! we already have fully extracted this file in a previous run.
864860 elif stat .S_ISDIR (st .st_mode ):
865861 os .rmdir (path )
862+ st = None
866863 else :
867864 os .unlink (path )
865+ st = None
868866 except UnicodeEncodeError :
869867 raise self .IncompatibleFilesystemEncodingError (path , sys .getfilesystemencoding ()) from None
870868 except OSError :
871- pass
869+ st = None
872870
873871 def make_parent (path ):
874872 parent_dir = os .path .dirname (path )
@@ -882,7 +880,7 @@ def make_parent(path):
882880 with self .extract_helper (item , path , hlm ) as hardlink_set :
883881 if hardlink_set :
884882 return
885- if self .compare_and_extract_chunks (item , path , pi = pi , sparse = sparse ):
883+ if self .compare_and_extract_chunks (item , path , st = st , pi = pi ):
886884 return
887885
888886 with backup_io ("open" ):
0 commit comments