put messages to FE in for del / restore. Also, added code to see if files in Bin/ path, if so do quick WARNING, with TODO on how to improve. Finally, when importing Bin paths, just do the intial AddPath (and AddDir), then bail out of further importing. Fixed misssing return on function too
This commit is contained in:
@@ -301,6 +301,7 @@ def ProcessRecycleBinDir(parent_job):
|
||||
paths = settings.recycle_bin_path.split("#")
|
||||
ptype = session.query(PathType).filter(PathType.name=='Bin').first().id
|
||||
JobsForPaths( parent_job, paths, ptype )
|
||||
return
|
||||
|
||||
def ProcessStorageDirs(parent_job):
|
||||
settings = session.query(Settings).first()
|
||||
@@ -775,6 +776,11 @@ def JobImportDir(job):
|
||||
# create/find the Path
|
||||
path_obj=AddPath( job, symlink, path_type )
|
||||
session.add(path_obj)
|
||||
# for recycle bin path, we dont want to import content, just create the path/dir vars (above) in the DB
|
||||
bin_path=session.query(Path).join(PathType).filter(PathType.name=='Bin').first()
|
||||
if path_type == bin_path.type.id:
|
||||
return
|
||||
|
||||
# find all jobs waiting on me and their children, etc. and add a path_prefix jex to symlink, so we can just reference it form here on in, rather than recreate that string
|
||||
AddJexToDependantJobs(job,"path_prefix",symlink)
|
||||
ResetExistsOnFS(job, symlink)
|
||||
@@ -1187,6 +1193,7 @@ def JobDeleteFiles(job):
|
||||
now=datetime.now(pytz.utc)
|
||||
next_job=Job(start_time=now, last_update=now, name="checkdups", state="New", wait_for=None, pa_job_state="New", current_file_num=0 )
|
||||
session.add(next_job)
|
||||
MessageToFE( job.id, "success", "Completed (delete of selected files)" )
|
||||
FinishJob(job, f"Finished deleting selected file(s)")
|
||||
return
|
||||
|
||||
@@ -1200,16 +1207,22 @@ def JobRestoreFiles(job):
|
||||
now=datetime.now(pytz.utc)
|
||||
next_job=Job(start_time=now, last_update=now, name="checkdups", state="New", wait_for=None, pa_job_state="New", current_file_num=0 )
|
||||
session.add(next_job)
|
||||
MessageToFE( job.id, "success", "Completed (restore of selected files)" )
|
||||
FinishJob(job, f"Finished restoring selected file(s)")
|
||||
return
|
||||
|
||||
def ValidateSettingsPaths():
|
||||
def InitialValidationChecks():
|
||||
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
|
||||
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)" )
|
||||
break
|
||||
if not rbp_exists:
|
||||
print("ERROR: The bin path in settings does not exist - Please fix now");
|
||||
@@ -1238,7 +1251,7 @@ def ValidateSettingsPaths():
|
||||
if __name__ == "__main__":
|
||||
print("INFO: PA job manager starting - listening on {}:{}".format( PA_JOB_MANAGER_HOST, PA_JOB_MANAGER_PORT) )
|
||||
|
||||
ValidateSettingsPaths()
|
||||
InitialValidationChecks()
|
||||
|
||||
HandleJobs()
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
|
||||
Reference in New Issue
Block a user