-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
move_file() fails if source and destination are not on the same file system #71
Comments
That's unfortunate. It seems there exists no secure and fast methods to move files around under Python. |
I think it is expected that moving a file from one system to another will be slower as it basically requires to copy the file and then delete in the old destination. So maybe we should simply catch the error and fallback to another move function. |
In principle, that's a good idea. But we have to make sure, that |
If there is a cheap way to find out if the two files are on different disks we could also check that first. On the other hand - if it raises a |
Here's my current workaround (on Linux): def safe_move(src: str, dst: str):
try:
audeer.move(src, dst)
except OSError as ex:
if 'Invalid cross-device link' in str(ex):
shutil.move(src, dst)
else:
raise ex |
One problem might be that the error messages are usually different for file system operations on different operating systems. The ideal solution would be to be able to create a test on the runners for having different file systems, but I'm not sure if this is possible (BTW, does this mean simply different partitions, or does this mean having EXT4 on one partition and NTFS on another one?). |
In my case I have two disks, both EXT4 formatted. |
I just encountered the following error when trying to use
audeer.move_file()
to move a file from one file system to another:We should either fix it or mention in the docstring that it's not possible.
The text was updated successfully, but these errors were encountered: