Skip to content

Commit b3751f7

Browse files
committed
Clean up variable names in Backup class
1 parent f51c3b7 commit b3751f7

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

bin/backup.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,14 @@ def split_share(share):
340340
341341
Args:
342342
share (String): The share to split.
343+
344+
Returns:
345+
dict[]: A list of shares to be split
346+
dict.share (String): The share to split
347+
dict.files (dict): The list of drive splits.
348+
Key (String) is a drive volume ID,
349+
Value (String[]) is a list of filenames for a given drive.
350+
dict.exclusions (String[]): The list of files to exclude from the split.
343351
"""
344352

345353
# Enumerate list for tracking what shares go where
@@ -362,6 +370,9 @@ def split_share(share):
362370
except PermissionError:
363371
pass
364372

373+
if self.thread_manager.threadlist['Backup Analysis']['killFlag']:
374+
return
375+
365376
# For splitting shares, sort by largest free space first
366377
drive_info.sort(reverse=True, key=lambda x: x['free'])
367378

@@ -373,6 +384,7 @@ def split_share(share):
373384
# number of combinations to check, we need to keep processing the file list
374385
# in chunks to make sure we check if all files can be fit on one drive
375386
files_that_fit_on_drive = []
387+
small_file_list = {}
376388
processed_small_files = []
377389
processed_file_size = 0
378390
while len(processed_small_files) < len(total_small_files):
@@ -468,34 +480,34 @@ def split_share(share):
468480

469481
# Each summary contains a split share, and any split subfolders, starting with
470482
# the share and recursing into the directories
471-
for directory in summary:
483+
for split in summary:
472484
if self.thread_manager.threadlist['Backup Analysis']['killFlag']:
473485
break
474486

475-
share_name = directory['share']
476-
share_files = directory['files']
477-
share_exclusions = directory['exclusions']
487+
share_name = split['share']
488+
share_files = split['files']
489+
share_exclusions = split['exclusions']
478490

479491
all_files = share_files.copy()
480492
all_files['exclusions'] = share_exclusions
481493

482494
# For each drive, gather list of files to be written to other drives, and
483495
# use that as exclusions
484-
for drive, files in share_files.items():
496+
for drive_vid, files in share_files.items():
485497
if len(files) > 0:
486498
raw_exclusions = all_files.copy()
487-
raw_exclusions.pop(drive, None)
499+
raw_exclusions.pop(drive_vid, None)
488500

489501
# Build master full exclusion list
490502
master_exclusions = [file for file_list in raw_exclusions.values() for file in file_list]
491503

492504
# Remove share if excluded in parent splitting
493-
if share_name in drive_exclusions[self.DRIVE_VID_INFO[drive]['name']]:
494-
drive_exclusions[self.DRIVE_VID_INFO[drive]['name']].remove(share_name)
505+
if share_name in drive_exclusions[self.DRIVE_VID_INFO[drive_vid]['name']]:
506+
drive_exclusions[self.DRIVE_VID_INFO[drive_vid]['name']].remove(share_name)
495507

496508
# Add new exclusions to list
497-
drive_exclusions[self.DRIVE_VID_INFO[drive]['name']].extend([os.path.join(share_name, file) for file in master_exclusions])
498-
drive_share_list[drive].append(share_name)
509+
drive_exclusions[self.DRIVE_VID_INFO[drive_vid]['name']].extend([os.path.join(share_name, file) for file in master_exclusions])
510+
drive_share_list[drive_vid].append(share_name)
499511

500512
if self.thread_manager.threadlist['Backup Analysis']['killFlag']:
501513
break
@@ -517,7 +529,7 @@ def recurse_file_list(directory):
517529
try:
518530
if len(os.scandir(directory)) > 0:
519531
for entry in os.scandir(directory):
520-
# For each entry, either add filesize to the total, or recurse into the directory
532+
# For each entry, either add file to list, or recurse into directory
521533
if entry.is_file():
522534
file_list.append(entry.path)
523535
elif entry.is_dir():

0 commit comments

Comments
 (0)