FIXED: BUG-32: sometimes still getting extra directories in Bin, that just have a trailing slash (or 2 or 3, etc.) -- Also improved Job logs for Del/Restore
This commit is contained in:
@@ -637,6 +637,8 @@ def RestoreFile(job,restore_me):
|
||||
new_rel_path=new_rel_path.replace(orig_file_details.orig_path_prefix, '')
|
||||
if len(new_rel_path) > 0 and new_rel_path[-1] == '/':
|
||||
new_rel_path=new_rel_path[0:-1]
|
||||
if len(new_rel_path) > 0 and new_rel_path[0] == '/':
|
||||
new_rel_path=new_rel_path[1:]
|
||||
|
||||
# path (think Import/Dir1/Dir2) which b/c we have orig_path in AddDir will
|
||||
# create static/Import, static/Import/Dir1, static/Import/Dir1/Dir2
|
||||
@@ -648,6 +650,7 @@ def RestoreFile(job,restore_me):
|
||||
part_rel_path += "/"
|
||||
|
||||
restore_me.in_dir = new_dir
|
||||
AddLogForJob(job, f"Restored file: {restore_me.name} to {os.path.dirname(restore_me.FullPathOnFS())}" )
|
||||
### DDP: when restoring, an original dir tree might have been removed, so need make it (if needed)
|
||||
os.makedirs( os.path.dirname(restore_me.FullPathOnFS()),mode=0o777, exist_ok=True )
|
||||
# remove DelFile entry for this restored file
|
||||
@@ -682,7 +685,7 @@ def MoveFileToRecycleBin(job,del_me):
|
||||
new_rel_path=del_me.in_dir.in_path.path_prefix.replace('static/','')
|
||||
# if there is a relative path on this dir, add it to the new_rel_path as there is only ever 1 Bin path
|
||||
if len(del_me.in_dir.rel_path):
|
||||
new_rel_path += '/' + del_me.in_dir.rel_path
|
||||
new_rel_path += '/' + del_me.in_dir.rel_path
|
||||
|
||||
# okay, go through new relative path and AddDir any missing subdirs of this
|
||||
# path (think Import/Dir1/Dir2) which b/c we have bin_path in AddDir will
|
||||
@@ -695,6 +698,7 @@ def MoveFileToRecycleBin(job,del_me):
|
||||
part_rel_path += "/"
|
||||
|
||||
del_me.in_dir = new_dir
|
||||
AddLogForJob(job, f"Deleted file: {del_me.name} - (moved to {os.path.dirname(del_me.FullPathOnFS())})" )
|
||||
return
|
||||
|
||||
|
||||
@@ -1188,7 +1192,6 @@ def JobDeleteFiles(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.name}" )
|
||||
MoveFileToRecycleBin(job,del_me)
|
||||
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 )
|
||||
@@ -1202,7 +1205,6 @@ def JobRestoreFiles(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}" )
|
||||
RestoreFile(job,restore_me)
|
||||
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 )
|
||||
|
||||
Reference in New Issue
Block a user