fixed Bug-75, moving dir between paths now works
This commit is contained in:
@@ -1037,25 +1037,29 @@ def MoveEntriesToOtherFolder(job, move_me, dst_storage_path, dst_rel_path):
|
||||
dst_dir=parent_dir.dir_details
|
||||
# remember, we are moving (move_me - a dir) into this existing dir (dst_dir), so add the name to dst_dir's rel_path...
|
||||
move_me.dir_details.rel_path = dst_dir.rel_path + '/' + move_me.name
|
||||
move_me.dir_details.in_path = dst_dir.in_path
|
||||
move_me.in_dir = dst_dir
|
||||
move_me.in_path = dst_dir.in_path
|
||||
session.add(move_me)
|
||||
# move the actual dir to its new location
|
||||
AddLogForJob( job, f"INFO: move {orig_fs_pos} -> {move_me.FullPathOnFS()}" )
|
||||
os.replace( orig_fs_pos, move_me.FullPathOnFS() )
|
||||
# we use the new path to this new Dir with the full location (the old dir is put into the new location)
|
||||
ResetAnySubdirPaths( move_me, dst_storage_path, move_me.dir_details.rel_path )
|
||||
# move the actual dir to its new location
|
||||
os.replace( orig_fs_pos, move_me.FullPathOnFS() )
|
||||
AddLogForJob( job, f"INFO: move {orig_fs_pos} -> {move_me.FullPathOnFS()}" )
|
||||
else:
|
||||
# scen 4: rename dir -- as the last component of dst_rel_path is what we will rename move_me to, so dont create last bit (os.path.dirname),
|
||||
# scen 3: rename dir -- as the last component of dst_rel_path is what we will rename move_me to, so dont create last bit (os.path.dirname),
|
||||
# we will just change move_me into that last dir -> renaming the dir
|
||||
dst_dir=CreateFSLocation( job, dst_storage_path, os.path.dirname(dst_rel_path) )
|
||||
|
||||
move_me.in_dir = dst_dir
|
||||
move_me.dir_details.rel_path = dst_rel_path
|
||||
move_me.dir_details.in_path = dst_dir.in_path
|
||||
move_me.in_dir = dst_dir
|
||||
move_me.in_path = dst_dir.in_path
|
||||
move_me.name = os.path.basename(dst_rel_path)
|
||||
session.add(move_me)
|
||||
ResetAnySubdirPaths( move_me, dst_storage_path, dst_rel_path )
|
||||
AddLogForJob( job, f"INFO: move {orig_fs_pos} -> {move_me.FullPathOnFS()}" )
|
||||
os.replace( orig_fs_pos, move_me.FullPathOnFS() )
|
||||
AddLogForJob( job, f"INFO: rename {orig_fs_pos} -> {move_me.FullPathOnFS()}" )
|
||||
return
|
||||
else:
|
||||
# make (any needed) Dir for the new destination FS location
|
||||
|
||||
Reference in New Issue
Block a user