added code to check paths exist on startup

This commit is contained in:
Damien De Paoli
2021-05-28 16:37:26 +10:00
parent 4ed76961a8
commit 9a9dc01c5a
2 changed files with 31 additions and 2 deletions

2
TODO
View File

@@ -1,6 +1,4 @@
## GENERAL
* on start up, should validate the import/storage/recycle bin paths exist and spit an error if they dont
* storage_path viewing needs to be by folder / not a big grab bag of files (by default - DONE)
-- BUG: issue with view by Day, etc. we print out day even if the Entry is not in the cwd
-- TODO: Need to toggle the view if I want, and when viewing storage area, change single-click to be view file again, and right-click to be my context menu

View File

@@ -1103,8 +1103,39 @@ def RemoveDups(job):
AddLogForJob(job, "adding <a href='/job/{}'>job id={} {}</a> to confirm there are no more duplicates".format( next_job.id, next_job.id, next_job.name ) )
return
def ValidateSettingsPaths():
settings = session.query(Settings).first()
rbp_exists=0
paths = settings.recycle_bin_path.split("#")
for path in paths:
if os.path.exists(path):
rbp_exists=1
break
if not rbp_exists:
print("ERROR: The bin path in settings does not exist - Please fix now");
sp_exists=0
paths = settings.storage_path.split("#")
for path in paths:
if os.path.exists(path):
sp_exists=1
break
if not sp_exists:
print("ERROR: None of the storge paths in the settings does not exist - Please fix now");
ip_exists=0
for path in paths:
if os.path.exists(path):
ip_exists=1
break
if not ip_exists:
print("ERROR: None of the import paths in the settings exist - Please fix now");
paths = settings.import_path.split("#")
return
if __name__ == "__main__":
print("INFO: PA job manager starting - listening on {}:{}".format( PA_JOB_MANAGER_HOST, PA_JOB_MANAGER_PORT) )
ValidateSettingsPaths()
# now=datetime.now(pytz.utc)
# job=Job(start_time=now, last_update=now, name="scannow", state="New", wait_for=None, pa_job_state="New", current_file_num=0, num_files=0 )