Crlaozwyn Posted March 7, 2021 Share Posted March 7, 2021 (edited) I'm finally organizing my media properly with TV, Movies, and Music on their own shares. I made a little Python script that handles incoming files, sorting them into their appropriate folder; it worked great when everything was on one share. Not that everything is on different shares, my script has the same symptoms as Windows Explorer - even though files are moving around on the same disk, the file is copied then deleted, taking a bunch of extra time and wasted read/write cycles. Midnight Commander, running on the server, works exactly as expected. Is there any way to emulate this functionality through Python? When everything was on the same share, os.rename() worked flawlessly, but now it throws an error about "different disk drives." I replaced it with shutil.move() but that does the whole copy nonsense. Is this because I'm running the Python script from Windows? If so, is there a way to run it through the server and would that fix the problem? The only Python environment I found was a PyCharm docker and that really wasn't a good solution, since the docker is sandboxed. Any help would be greatly appreciated. Thanks! Edited March 7, 2021 by Crlaozwyn Add Solved tag to title Quote Link to comment
Squid Posted March 7, 2021 Share Posted March 7, 2021 Every OS in the world suffers the same "flaw". Renames across mount points (shares) always does a copy / delete instead of a rename operation. It's the proper way to do things, and is 100% correct, regardless if the files / shares are actually on the same drive or not. Quote Link to comment
Crlaozwyn Posted March 7, 2021 Author Share Posted March 7, 2021 2 hours ago, Squid said: Every OS in the world suffers the same "flaw". Renames across mount points (shares) always does a copy / delete instead of a rename operation. It's the proper way to do things, and is 100% correct, regardless if the files / shares are actually on the same drive or not. Thanks Squid. I appreciate the response. MC does not appear to copy/delete, as "moving" a 10GB file happens instantly. The issue, if it really was an issue at all, was that I was running the Python script from Windows, which didn't recognize the shares as being on the same drive. Once I ran the script on the server, it was instant again. However, I've realized in testing that this behavior ignores split level settings for the share. I suppose my use-case is more complicated than I thought, because what I actually want is for it to move the pointer when the end point (EG season/artist) is on the same drive, but follow the split level settings to put it on the proper drive if different. Looks like I'll be writing some manual tests to determine start/endpoint drives and choose a command based on which outcome is needed. Quote Link to comment
Squid Posted March 7, 2021 Share Posted March 7, 2021 2 hours ago, Crlaozwyn said: MC does not appear to copy/delete, as "moving" a 10GB file happens instantly Because the command line bypasses the entire system of mount points, since you're navigating on both to be /mnt/user/abc and /mnt/user/def so the mount point in both cases is /mnt/user 2 hours ago, Crlaozwyn said: However, I've realized in testing that this behavior ignores split level settings for the share. Along with included / excluded, useCache settings. Because of the single mountpoint Quote Link to comment
Crlaozwyn Posted March 7, 2021 Author Share Posted March 7, 2021 2 hours ago, Squid said: Because the command line bypasses the entire system of mount points, since you're navigating on both to be /mnt/user/abc and /mnt/user/def so the mount point in both cases is /mnt/user Along with included / excluded, useCache settings. Because of the single mountpoint Thanks for the clarity - helps explain what I'm seeing. I'll do some more testing to see if the move command works as desired or if I need to emulate the functionality. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.