@@ -127,7 +127,7 @@ def download_dbs_contents(self, db_pkgs: list[DbSectionPackage], full_resync: bo
127
127
box .add_processed_files (job .non_duplicated_files , job .db .db_id )
128
128
box .add_present_validated_files (job .present_validated_files )
129
129
box .add_skipped_updated_files (job .skipped_updated_files , job .db .db_id )
130
- box .add_removed_copies (job .removed_folders )
130
+ box .add_removed_copies (job .removed_folders , job . db . db_id )
131
131
box .add_installed_folders (job .installed_folders )
132
132
box .queue_directory_removal (job .directories_to_remove , job .db .db_id )
133
133
box .queue_file_removal (job .files_to_remove , job .db .db_id )
@@ -145,7 +145,7 @@ def download_dbs_contents(self, db_pkgs: list[DbSectionPackage], full_resync: bo
145
145
box .add_processed_files (job .non_duplicated_files , job .db .db_id )
146
146
box .add_present_validated_files (job .present_validated_files )
147
147
box .add_skipped_updated_files (job .skipped_updated_files , job .db .db_id )
148
- box .add_removed_copies (job .removed_folders )
148
+ box .add_removed_copies (job .removed_folders , job . db . db_id )
149
149
box .add_installed_folders (job .installed_folders )
150
150
box .queue_directory_removal (job .directories_to_remove , job .db .db_id )
151
151
box .queue_file_removal (job .files_to_remove , job .db .db_id )
@@ -278,97 +278,36 @@ def download_dbs_contents(self, db_pkgs: list[DbSectionPackage], full_resync: bo
278
278
stores [db_id ].write_only ().remove_folder (pkg .rel_path )
279
279
stores [db_id ].write_only ().remove_folder_from_zips (pkg .rel_path )
280
280
281
- external_parents_by_db : dict [str , dict [str , set [str ]]] = defaultdict (lambda : defaultdict (set ))
282
- parents_by_db : dict [str , set [str ]] = defaultdict (set )
283
- all_parents_by_db : dict [str , dict [str , set [str ]]] = defaultdict (lambda : defaultdict (set ))
284
-
285
- def add_parent (el_pkg : PathPackage , db_id : str ) -> None :
286
- if el_pkg .pext_props is not None :
287
- if el_pkg .is_pext_standard ():
288
- parents_by_db [db_id ].add (el_pkg .pext_props .parent )
289
- else :
290
- external_parents_by_db [db_id ][el_pkg .pext_props .parent ].add (el_pkg .pext_props .drive )
291
-
292
281
for file_path in box .installed_files ():
293
282
file = box .processed_file (file_path )
294
283
if 'reboot' in file .pkg .description and file .pkg .description ['reboot' ] == True :
295
284
self ._needs_reboot = True
296
-
297
- add_parent (file .pkg , file .db_id )
298
- all_parents_by_db [file .db_id ][file .pkg .parent ].add (file .pkg .drive )
299
-
300
- for file_path in box .installed_files ():
301
- file = box .processed_file (file_path )
302
-
303
- for is_external , other_drive in stores [file .db_id ].read_only ().list_other_drives_for_file (file .pkg .rel_path , file .pkg .pext_drive ()):
304
- other_file = os .path .join (other_drive , file .pkg .rel_path )
305
- if not self ._worker_ctx .file_system .is_file (other_file ):
306
- if is_external :
307
- stores [file .db_id ].write_only ().remove_external_file (other_drive , file .pkg .rel_path )
308
- else :
309
- stores [file .db_id ].write_only ().remove_local_file (file .pkg .rel_path )
310
-
311
285
stores [file .db_id ].write_only ().add_file_pkg (file .pkg )
312
286
313
- if file .pkg .pext_props is not None :
314
- for other in file .pkg .pext_props .other_drives :
315
- if self ._worker_ctx .file_system .is_file (os .path .join (other , file .pkg .rel_path )):
316
- stores [file .db_id ].write_only ().add_external_file (other , file .pkg .rel_path , file .pkg .description )
317
-
318
287
for folder_path in sorted (box .installed_folders (), key = lambda x : len (x ), reverse = True ):
319
288
for db_id , folder_pkg in report .processed_folder (folder_path ).items ():
320
- if folder_pkg .is_pext_parent ():
321
- continue
322
-
323
289
stores [db_id ].write_only ().add_folder_pkg (folder_pkg )
324
- add_parent (folder_pkg , db_id )
325
-
326
- for folder_path in sorted (box .installed_folders (), key = lambda x : len (x ), reverse = True ):
327
- for db_id , folder_pkg in report .processed_folder (folder_path ).items ():
328
- if not folder_pkg .is_pext_parent ():
329
- continue
330
-
331
- if folder_pkg .pext_props .parent in parents_by_db [db_id ]:
332
- stores [db_id ].write_only ().add_folder (folder_pkg .rel_path , folder_pkg .description )
333
- if folder_pkg .pext_props .parent in external_parents_by_db [db_id ]:
334
- for drive in external_parents_by_db [db_id ][folder_pkg .pext_props .parent ]:
335
- stores [db_id ].write_only ().add_external_folder (drive , folder_pkg .rel_path , folder_pkg .description )
336
290
337
291
for file_path in box .removed_files ():
338
292
file = box .processed_file (file_path )
339
- stores [file .db_id ].write_only ().remove_file (file .pkg . rel_path )
293
+ stores [file .db_id ].write_only ().remove_file_pkg (file .pkg )
340
294
341
- for is_external , el_path , drive , ty in box .removed_copies ():
295
+ for db_id , is_external , el_path , drive , ty in box .removed_copies ():
342
296
if ty == PathType .FILE :
343
297
file = box .processed_file (el_path )
344
- if is_external :
345
- stores [file .db_id ].write_only ().remove_external_file (drive , el_path )
346
- else :
347
- stores [file .db_id ].write_only ().remove_local_file (el_path )
298
+ stores [file .db_id ].write_only ().remove_file_pkg (file .pkg )
348
299
349
300
elif ty == PathType .FOLDER :
350
- for db_id , folder_pkg in report .processed_folder (el_path ).items ():
351
- if is_external :
352
- stores [db_id ].write_only ().remove_external_folder (drive , el_path )
353
- else :
354
- stores [db_id ].write_only ().remove_local_folder (el_path )
301
+ if is_external :
302
+ stores [db_id ].write_only ().remove_external_folder (el_path )
303
+ else :
304
+ stores [db_id ].write_only ().remove_folder (el_path )
355
305
356
306
for db_id , zip_id , zip_summary , zip_description in box .installed_zip_summary ():
357
307
stores [db_id ].write_only ().add_zip_summary (zip_id , zip_summary , zip_description )
358
308
359
- filtered_zip_data = {}
360
- for db_id , zip_id , files , folders in box .filtered_zip_data ():
361
- if db_id not in filtered_zip_data :
362
- filtered_zip_data [db_id ] = {}
363
-
364
- if zip_id not in filtered_zip_data [db_id ]:
365
- filtered_zip_data [db_id ][zip_id ] = {'files' : {}, 'folders' : {}}
366
-
367
- filtered_zip_data [db_id ][zip_id ]['files' ].update (files )
368
- filtered_zip_data [db_id ][zip_id ]['folders' ].update (folders )
369
-
370
- for db_id , filtered_zip_data_by_db in filtered_zip_data .items ():
371
- stores [db_id ].write_only ().save_filtered_zip_data (filtered_zip_data_by_db )
309
+ for db_id , filtered_zip_data in box .filtered_zip_data ().items ():
310
+ stores [db_id ].write_only ().save_filtered_zip_data (filtered_zip_data )
372
311
373
312
for store in stores .values ():
374
313
store .write_only ().cleanup_externals ()
@@ -459,10 +398,10 @@ def __init__(self):
459
398
self ._full_partitions : dict [str , int ] = dict ()
460
399
self ._failed_db_options : list [WrongDatabaseOptions ] = []
461
400
self ._removed_files : list [str ] = []
462
- self ._removed_copies : list [RemovedCopy ] = []
401
+ self ._removed_copies : list [tuple [ str , bool , str , str , PathType ] ] = []
463
402
self ._removed_zips : list [tuple [str , str ]] = []
464
403
self ._skipped_updated_files : dict [str , list [str ]] = dict ()
465
- self ._filtered_zip_data : list [ tuple [ str , str , dict [str , Any ], dict [str , Any ]]] = []
404
+ self ._filtered_zip_data : dict [ str , dict [ str , dict [str , dict [str , Any ]]]] = defaultdict ( dict )
466
405
self ._installed_zip_summary : list [tuple [str , str , StoreFragmentDrivePaths , dict [str , Any ]]] = []
467
406
self ._installed_folders : set [str ] = set ()
468
407
self ._directories = dict ()
@@ -534,9 +473,7 @@ def add_installed_db(self, db: DbEntity):
534
473
def add_updated_db (self , db_id : str ):
535
474
self ._updated_dbs .append (db_id )
536
475
def add_filtered_zip_data (self , db_id : str , zip_id : str , filtered_data : FileFoldersHolder ) -> None :
537
- files , folders = filtered_data ['files' ], filtered_data ['folders' ]
538
- #if len(files) == 0 and len(folders) == 0: return
539
- self ._filtered_zip_data .append ((db_id , zip_id , files , folders ))
476
+ self ._filtered_zip_data [db_id ][zip_id ] = filtered_data
540
477
def add_failed_db_options (self , exception : WrongDatabaseOptions ):
541
478
self ._failed_db_options .append (exception )
542
479
def add_removed_file (self , file : str ):
@@ -545,9 +482,9 @@ def add_removed_files(self, files: list[PathPackage]):
545
482
if len (files ) == 0 : return
546
483
for pkg in files :
547
484
self ._removed_files .append (pkg .rel_path )
548
- def add_removed_copies (self , copies : list [RemovedCopy ]):
485
+ def add_removed_copies (self , copies : list [RemovedCopy ], db_id : str ):
549
486
if len (copies ) == 0 : return
550
- self ._removed_copies .extend (copies )
487
+ self ._removed_copies .extend ([( db_id , is_external , folder_path , other_drive , el_kind ) for is_external , folder_path , other_drive , el_kind in copies ] )
551
488
def add_installed_folders (self , folders : list [PathPackage ]):
552
489
if len (folders ) == 0 : return
553
490
for pkg in folders :
0 commit comments