detecting empty wallets where we only have JSON and no files

This commit is contained in:
Philip Sargent
2022-08-16 20:02:28 +03:00
parent e94dc6eb6f
commit 41c68aef26
3 changed files with 29 additions and 6 deletions

View File

@@ -110,11 +110,25 @@ def load_all_scans():
CheckEmptyPeople(wallet)
wallet.save()
LoadListScansFile(wallet)
else:
# but We should load all the scans, even for nonstandard names.
print(f'\n - IGNORE {walletname} - {fpath}')
# but we also need to check if JSON exists, even if there are no uploaded scan files
contents_path = Path(settings.DRAWINGS_DATA, "walletjson")
for yeardir in contents_path.iterdir():
if yeardir.is_dir():
for walletpath in yeardir.iterdir():
if Path(walletpath, contentsjson).is_file():
walletname = walletpath.name
wallet, created = Wallet.objects.update_or_create(walletname=walletname)
if created:
print(f"\n{walletname} created: only JSON, no actual uploaded scan files.", end=' ')
CheckEmptyDate(wallet)
CheckEmptyPeople(wallet)
wallet.save()
print("", flush=True)