finished moving GenerateFileData out of files.py into pa_job_manager.py

This commit is contained in:
2021-01-17 11:31:06 +11:00
parent a89f7fdb2b
commit abff2d8bab
4 changed files with 33 additions and 147 deletions

View File

@@ -165,8 +165,10 @@ class FileData():
path_prefix=symlink.replace(path,"")
file_obj = File( name=fname, type=ftype, size_mb=fsize, hash=fhash, path_prefix=path_prefix, thumbnail=fthumbnail )
session.add(file_obj)
AddLogForJob(job, "DEBUG: {} - {} is OLDER than {}".format( file, stat.st_ctime, last_import_date ), file )
AddLogForJob(job, "Found new file: {}".format(fname) )
else:
AddLogForJob(job, "{} - {} is OLDER than {}".format( file, stat.st_ctime, last_import_date ), file )
AddLogForJob(job, "DEBUG: {} - {} is OLDER than {}".format( file, stat.st_ctime, last_import_date ), file )
settings.last_import_date = time.time()
session.commit()
return self
@@ -287,7 +289,7 @@ def RunJob(job):
if job.name =="scannow":
JobScanNow(job)
elif job.name =="forcescan":
print("force scan not being handled yet")
JobForceScan(job)
else:
print("Requested to process unknown job type: {}".format(job.name))
except Exception as e:
@@ -298,6 +300,8 @@ def HandleJobs():
print("PA job manager is scanning for jobs")
pa_eng.state = 'Scanning Jobs'
jobs=GetJobs()
pa_eng.num_active_jobs=0
pa_eng.num_completed_jobs=0
for job in jobs:
if job.pa_job_state != 'Completed':
RunJob(job)
@@ -317,6 +321,22 @@ def JobScanNow(job):
session.commit()
return
def JobForceScan(job):
session.query(File).delete()
settings = session.query(Settings).first()
if settings == None:
raise Exception("Cannot create file data with no settings / import path is missing")
settings.last_import_date = 0
session.commit()
filedata.GenerateFileData(job)
job.state="Completed"
job.pa_job_state="Completed"
job.last_update=datetime.now(pytz.utc)
MessageToFE( job.id, "success", "Completed (forced remove and recreation of all file data)" )
session.commit()
return
if __name__ == "__main__":
print("PA job manager starting")
try: