moved InitValidation checks to log to a Job to show errors in front-end, and moved the creation of the symlinks to the InitValidation so we can restart paweb docker container and it will recreate the symlinks in static without needing an import. Also added token highlighting of a failed job

This commit is contained in:
2021-06-22 19:30:04 +10:00
parent 9eb82bf1c3
commit eb574e3c75
3 changed files with 30 additions and 13 deletions

View File

@@ -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

View File

@@ -25,7 +25,11 @@
</div>
<div class="row col-lg-12">
<label class="form-control-plaintext col-lg-2">Current state:</label>
{% if job.state != "Complete" %}
<label class="form-control-plaintext col-lg-10" style="background-color:red">{{job.state}}</label>
{% else %}
<label class="form-control-plaintext col-lg-10">{{job.state}}</label>
{% endif %}
</div>
{% if job.wait_for != None %}
<div class="row col-lg-12">

View File

@@ -7,7 +7,11 @@
var completed_rows=Array()
{% for job in jobs %}
{% if job.state == "Failed" %}
row='<tr><td style="background-color:red"><a href="{{url_for('joblog', id=job.id)}}">Job #{{job.id}} - {{job.name}}</a>'
{% else %}
row='<tr><td><a href="{{url_for('joblog', id=job.id)}}">Job #{{job.id}} - {{job.name}}</a>'
{% endif %}
{% if job.name != "rmdups" %}
{% for ex in job.extra %}
{% if 'path' == ex.name or ('path_prefix'==ex.name and job.name == 'checkdups') %}