changed to consistently use restore instead of awful undelete
This commit is contained in:
@@ -399,8 +399,8 @@ def RunJob(job):
|
||||
RemoveDups(job)
|
||||
elif job.name == "delete_files":
|
||||
JobDeleteFiles(job)
|
||||
elif job.name == "undelete_files":
|
||||
JobUnDeleteFiles(job)
|
||||
elif job.name == "restore_files":
|
||||
JobRestoreFiles(job)
|
||||
elif job.name == "processai":
|
||||
JobProcessAI(job)
|
||||
else:
|
||||
@@ -608,10 +608,10 @@ def RemoveFileFromFS( del_me ):
|
||||
print( f"ERROR: Failed to remove file from filesystem - which={src}, err: {e}")
|
||||
return
|
||||
|
||||
# Function that undeletes a file that was deleted (moved into the Bin)
|
||||
# Function that restores a file that was deleted (moved into the Bin)
|
||||
# it moves file on the filesystem back to its original path and then changes the database path from the Bin path
|
||||
# to the original import or storage path and appropriate dir
|
||||
def UnDeleteFile(job,restore_me):
|
||||
def RestoreFile(job,restore_me):
|
||||
try:
|
||||
# rel_path for a file in the Bin, is like 'Import/images_to_process/1111', so just prepend static/
|
||||
dst_dir='static/' + restore_me.in_dir.rel_path + '/'
|
||||
@@ -620,7 +620,7 @@ def UnDeleteFile(job,restore_me):
|
||||
dst=dst_dir + '/' + restore_me.name
|
||||
os.replace( src, dst )
|
||||
except Exception as e:
|
||||
print( f"ERROR: Failed to undelete (mv) file on filesystem - which={src} to {dst}, err: {e}")
|
||||
print( f"ERROR: Failed to restores (mv) file on filesystem - which={src} to {dst}, err: {e}")
|
||||
|
||||
# need these for AddDir calls below to work
|
||||
orig_file_details = session.query(DelFile).get(restore_me.id)
|
||||
@@ -670,7 +670,7 @@ def MoveFileToRecycleBin(job,del_me):
|
||||
parent_dir=session.query(Dir).join(PathDirLink).filter(PathDirLink.path_id==bin_path.id).first()
|
||||
|
||||
print( f"need to keep this (ind): {del_me.in_dir.in_path.path_prefix}" )
|
||||
# if we ever need to undelete, lets remember this file's original path
|
||||
# if we ever need to restore, lets remember this file's original path
|
||||
# (use a string in case the dir/path is ever deleted from FS (and then DB) and we need to recreate)
|
||||
del_file_details = DelFile( file_eid=del_me.id, orig_path_prefix=del_me.in_dir.in_path.path_prefix )
|
||||
session.add( del_file_details )
|
||||
@@ -1178,14 +1178,14 @@ def JobDeleteFiles(job):
|
||||
FinishJob(job, f"Finished deleting selected file(s)")
|
||||
return
|
||||
|
||||
def JobUnDeleteFiles(job):
|
||||
AddLogForJob(job, f"INFO: Starting Undelete Files job...")
|
||||
def JobRestoreFiles(job):
|
||||
AddLogForJob(job, f"INFO: Starting Restore Files job...")
|
||||
for jex in job.extra:
|
||||
if 'eid-' in jex.name:
|
||||
restore_me=session.query(Entry).join(File).filter(Entry.id==jex.value).first()
|
||||
AddLogForJob(job, f"INFO: Removing file: #{restore_me.id} -> {restore_me}" )
|
||||
UnDeleteFile(job,restore_me)
|
||||
FinishJob(job, f"Finished undeleting selected file(s)")
|
||||
RestoreFile(job,restore_me)
|
||||
FinishJob(job, f"Finished restoring selected file(s)")
|
||||
return
|
||||
|
||||
def ValidateSettingsPaths():
|
||||
|
||||
Reference in New Issue
Block a user