added JobDeleteFiles plumbing / tested... removed test code for Undel, and added in CheckDups call for Undel - that is untested though, so debug to that effect still in this commit
This commit is contained in:
@@ -397,6 +397,8 @@ def RunJob(job):
|
|||||||
CheckForDups(job)
|
CheckForDups(job)
|
||||||
elif job.name == "rmdups":
|
elif job.name == "rmdups":
|
||||||
RemoveDups(job)
|
RemoveDups(job)
|
||||||
|
elif job.name == "delete_files":
|
||||||
|
JobDeleteFiles(job)
|
||||||
elif job.name == "processai":
|
elif job.name == "processai":
|
||||||
JobProcessAI(job)
|
JobProcessAI(job)
|
||||||
else:
|
else:
|
||||||
@@ -643,7 +645,8 @@ def UnDeleteFile(job,restore_me):
|
|||||||
restore_me.in_dir = new_dir
|
restore_me.in_dir = new_dir
|
||||||
session.query(DelFile).filter(DelFile.file_eid==restore_me.id).delete()
|
session.query(DelFile).filter(DelFile.file_eid==restore_me.id).delete()
|
||||||
session.commit()
|
session.commit()
|
||||||
print("TODO: enqueue check_dups job")
|
CheckForDups(job)
|
||||||
|
print("TODO: test the check_dups above works")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Function that moves a file we are "deleting" to the recycle bin, it moves the
|
# Function that moves a file we are "deleting" to the recycle bin, it moves the
|
||||||
@@ -1126,8 +1129,6 @@ def RemoveDups(job):
|
|||||||
for del_me in del_me_lst:
|
for del_me in del_me_lst:
|
||||||
AddLogForJob(job, f"Remove duplicate (per file dup) file: {del_me.FullPathOnFS()}" )
|
AddLogForJob(job, f"Remove duplicate (per file dup) file: {del_me.FullPathOnFS()}" )
|
||||||
MoveFileToRecycleBin(job,del_me)
|
MoveFileToRecycleBin(job,del_me)
|
||||||
# RemoveFileFromFS( del_me )
|
|
||||||
# RemoveFileFromDB(del_me.id)
|
|
||||||
|
|
||||||
if 'kdid-' in jex.name:
|
if 'kdid-' in jex.name:
|
||||||
_, which = jex.name.split('-')
|
_, which = jex.name.split('-')
|
||||||
@@ -1152,8 +1153,7 @@ def RemoveDups(job):
|
|||||||
else:
|
else:
|
||||||
AddLogForJob(job, f"Keep duplicate file: {found.FullPathOnFS()}" )
|
AddLogForJob(job, f"Keep duplicate file: {found.FullPathOnFS()}" )
|
||||||
AddLogForJob(job, f"Remove duplicate (per path dup) file: {del_me.FullPathOnFS()}" )
|
AddLogForJob(job, f"Remove duplicate (per path dup) file: {del_me.FullPathOnFS()}" )
|
||||||
RemoveFileFromFS( del_me )
|
MoveFileToRecycleBin(job,del_me)
|
||||||
RemoveFileFromDB(del_me.id)
|
|
||||||
dup_cnt += 1
|
dup_cnt += 1
|
||||||
|
|
||||||
FinishJob(job, f"Finished removing {dup_cnt} duplicate files" )
|
FinishJob(job, f"Finished removing {dup_cnt} duplicate files" )
|
||||||
@@ -1166,6 +1166,17 @@ 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 ) )
|
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
|
return
|
||||||
|
|
||||||
|
def JobDeleteFiles(job):
|
||||||
|
AddLogForJob(job, f"INFO: Starting Remove Files job...")
|
||||||
|
for jex in job.extra:
|
||||||
|
if 'eid-' in jex.name:
|
||||||
|
del_me=session.query(Entry).join(File).filter(Entry.id==jex.value).first()
|
||||||
|
AddLogForJob(job, f"INFO: Removing file: #{del_me.id} -> {del_me}" )
|
||||||
|
MoveFileToRecycleBin(job,del_me)
|
||||||
|
FinishJob(job, f"Finished removing selected file(s)")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
def ValidateSettingsPaths():
|
def ValidateSettingsPaths():
|
||||||
settings = session.query(Settings).first()
|
settings = session.query(Settings).first()
|
||||||
rbp_exists=0
|
rbp_exists=0
|
||||||
@@ -1203,10 +1214,6 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
ValidateSettingsPaths()
|
ValidateSettingsPaths()
|
||||||
|
|
||||||
# restore_me=session.query(Entry).join(File).join(DelFile).first()
|
|
||||||
# if restore_me:
|
|
||||||
# UnDeleteFile(Job(),restore_me)
|
|
||||||
|
|
||||||
HandleJobs()
|
HandleJobs()
|
||||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||||
s.bind((PA_JOB_MANAGER_HOST, PA_JOB_MANAGER_PORT))
|
s.bind((PA_JOB_MANAGER_HOST, PA_JOB_MANAGER_PORT))
|
||||||
|
|||||||
Reference in New Issue
Block a user