Skip to content
This repository has been archived by the owner on Nov 18, 2022. It is now read-only.

Copy files to destination without metadata #2

Merged
merged 1 commit into from
Sep 2, 2015

Conversation

rcdailey
Copy link
Contributor

This is to support mounts to SAMBA shares or NTFS partitions. Those
filesystems do not support file permission bitflags or other POSIX
metadata. shutil.move, shutil.copy2 and shutil.copy all copy the
file and then attempt to do chmod or copy stats over.

This change literally only copies the files. Permission flags are
untouched. This shouldn't be a problem in theory since the destination
will either not need that information or have inheritable permissions
already properly set.

Without this change, previous behavior resulted in copies properly
happening but nzbget would show them as post-processing failures
because the copystat piece was failing, if the target directory was
a SAMBA share.

@hugbug
Copy link
Member

hugbug commented Aug 31, 2015

Now it always copies even if both the source and destination are on the same partition. Not good.

Can the error which occurs in shutil.move when setting permissions be detected and ignored? If it can't - the code should check (somehow) if the source and destiantion are on the same partition and use either "move" of "copy" approach.

@rcdailey
Copy link
Contributor Author

I don't understand. move wouldn't have behaved differently if it were on the same partition or not before. Can you clarify?

@hugbug
Copy link
Member

hugbug commented Sep 1, 2015

"Move" instantly renames, "copy" takes a lot of time.

@hugbug
Copy link
Member

hugbug commented Sep 1, 2015

From python docs:

shutil.move(src, dst)
Recursively move a file or directory (src) to another location (dst).

If the destination is on the current filesystem, then os.rename() is used. Otherwise, src is copied (using shutil.copy2()) to dst and then removed.

@rcdailey
Copy link
Contributor Author

rcdailey commented Sep 1, 2015

I see what you mean now, I missed that behavior. I have made some modifications, please review again.

@rcdailey
Copy link
Contributor Author

rcdailey commented Sep 1, 2015

Another question is, how can I print the [WARN] I have in there so it really shows up as a warning in the GUI log viewer in nzbget?

@hugbug
Copy link
Member

hugbug commented Sep 1, 2015

You cam use [WARNING] but I wouldn't to do that in this case because it's an expected behavior here. [DETAIL] would be OK if you want a message for debug purposes.

This is to support mounts to SAMBA shares or NTFS partitions. Those
filesystems do not support file permission bitflags or other POSIX
metadata. `shutil.move`, `shutil.copy2` and `shutil.copy` all copy the
file *and then* attempt to do `chmod` or copy stats over.

This change literally only copies the files. Permission flags are
untouched. This shouldn't be a problem in theory since the destination
will either not need that information *or* have inheritable permissions
already properly set.

Without this change, previous behavior resulted in copies properly
happening but nzbget would show them as post-processing failures
because the `copystat` piece was failing, if the target directory was
a SAMBA share.
@rcdailey
Copy link
Contributor Author

rcdailey commented Sep 1, 2015

Updated the code to use [DETAIL] per your recommendation. Thanks!

hugbug added a commit that referenced this pull request Sep 2, 2015
fixed: possible failure if the target directory was a SAMBA share on NTFS partition
@hugbug hugbug merged commit 575cb5b into nzbget:master Sep 2, 2015
@rcdailey rcdailey deleted the move-to-samba-mount branch October 27, 2015 12:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants