diff --git a/pa_job_manager.py b/pa_job_manager.py index e886c9b..549febf 100644 --- a/pa_job_manager.py +++ b/pa_job_manager.py @@ -776,7 +776,7 @@ def JobImportDir(job): if not os.path.exists( path ): FinishJob( job, f"Finished Importing: {path} -- Path does not exist", "Failed" ) return - symlink=CreateSymlink(job,path_type,path) + symlink=SymlinkName(path_type.name, path, path) # create/find the Path path_obj=AddPath( job, symlink, path_type ) @@ -1232,39 +1232,48 @@ def JobRestoreFiles(job): return def InitialValidationChecks(): + now=datetime.now(pytz.utc) + job=Job(start_time=now, last_update=now, name="init", state="New", wait_for=None, pa_job_state="New", current_file_num=0 ) + session.add(job) settings = session.query(Settings).first() rbp_exists=0 paths = settings.recycle_bin_path.split("#") + AddLogForJob(job, f"INFO: Starting Initial Validation checks...") for path in paths: if os.path.exists(path): rbp_exists=1 + ptype = session.query(PathType).filter(PathType.name=='Bin').first().id + symlink=CreateSymlink(job,ptype,path) path, dirs, files = next(os.walk(path)) if len(dirs) + len(files) > 0: - print("INFO: the bin path contains content, cannot process to know where original deletes were form - skipping content!" ) - print("TODO: could be smart about what is known in the DB vs on the FS, and change below to an ERROR if it is one") - print("WARNING: IF the files in the bin are in the DB (succeeded from GUI deletes) then this is okay, otherwise you should delete contents form the recycle bin and restart the job manager)" ) + AddLogForJob(job, "NFO: the bin path contains content, cannot process to know where original deletes were form - skipping content!" ) + AddLogForJob(job, "ODO: could be smart about what is known in the DB vs on the FS, and change below to an ERROR if it is one") + AddLogForJob(job, "ARNING: IF the files in the bin are in the DB (succeeded from GUI deletes) then this is okay, otherwise you should delete contents form the recycle bin and restart the job manager)" ) break if not rbp_exists: - print("ERROR: The bin path in settings does not exist - Please fix now"); + AddLogForJob(job, "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 + ptype = session.query(PathType).filter(PathType.name=='Storage').first().id + symlink=CreateSymlink(job,ptype,path) if not sp_exists: - print("ERROR: None of the storage paths in the settings exist - Please fix now"); + AddLogForJob(job, "ERROR: None of the storage paths in the settings exist - Please fix now"); ip_exists=0 + paths = settings.import_path.split("#") for path in paths: if os.path.exists(path): ip_exists=1 - break + ptype = session.query(PathType).filter(PathType.name=='Import').first().id + symlink=CreateSymlink(job,ptype,path) if not ip_exists: - print("ERROR: None of the import paths in the settings exist - Please fix now"); - paths = settings.import_path.split("#") + AddLogForJob(job, "ERROR: None of the import paths in the settings exist - Please fix now"); if not rbp_exists or not sp_exists or not ip_exists: - print("ERROR: Exiting until above errors are fixed by paths being created or settings being updated to valid paths" ) + FinishJob(job,"ERROR: Job manager EXITing until above errors are fixed by paths being created or settings being updated to valid paths", "Failed" ) exit(-1) + FinishJob(job,"Finished Initial Validation Checks") return diff --git a/templates/joblog.html b/templates/joblog.html index 8890bbf..783cd73 100644 --- a/templates/joblog.html +++ b/templates/joblog.html @@ -25,7 +25,11 @@