@@ -98,7 +98,7 @@ def save_file(local_pth: Path, file: bytes) -> None:
9898 local_pth .parent .mkdir (exist_ok = True , parents = True )
9999
100100 logger .info (f'Saving { local_pth .stem !r} to { local_pth } ' )
101- with open (local_pth , 'wb ' ) as file_output :
101+ with local_pth . open ('wb' , encoding = 'utf-8 ' ) as file_output :
102102 file_output .write (file )
103103 file_output .flush ()
104104 os .fsync (file_output .fileno ())
@@ -107,7 +107,7 @@ def save_file(local_pth: Path, file: bytes) -> None:
107107def save_records (file_records : list [dict ], json_md : Path ) -> None :
108108 """Persist today's file metadata to json file."""
109109 logger .info ('Saving file records to metadata json file' )
110- with open (json_md , 'wt ' ) as json_out :
110+ with json_md . open ('wt' , encoding = 'utf-8 ' ) as json_out :
111111 print (json .dumps (file_records ), file = json_out )
112112
113113
@@ -116,7 +116,7 @@ def previous_record_gen(json_md: Path, *, previous=None) -> Iterator[tuple[str,
116116 relevant info needed to instantiate file objects.
117117 """
118118 try :
119- with open (json_md ) as json_in :
119+ with json_md . open (encoding = 'utf-8' ) as json_in :
120120 previous = json .loads (json_in .read ())
121121 except FileNotFoundError :
122122 logger .warning ('Unable to locate metadata file. Creating new file' )
@@ -136,9 +136,7 @@ def previous_record_gen(json_md: Path, *, previous=None) -> Iterator[tuple[str,
136136
137137def check_for_deleted (current : set , previous : set ) -> list [SnFiles ]:
138138 """Look for files no longer on device from last backup."""
139- symmetric = current .symmetric_difference (previous )
140- return [file for file in symmetric if file not in current ]
141-
139+ return list (previous - current )
142140
143141def prepare_upload (ufile : list ) -> Iterator [dict [str , tuple [str , bytes , str ]]]:
144142 """Prepare file upload to send to device."""
0 commit comments