Skip to content
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

Use NSFileManager.moveItemAtURL() as a fallback of rename() system call when EXDEV error occurred #713

Merged
merged 2 commits into from Sep 9, 2015

Conversation

ikesyo
Copy link
Member

@ikesyo ikesyo commented Aug 25, 2015

Should fix #706 and #711.

The manpage of rename() says:

Both old and new must be of the same type (that is, both must be either directories or non-directories) and must reside on the same file system.

On the other hand, the documentation of NSFileManager.moveItemAtURL() says:

If the source and destination of the move operation are not on the same volume, this method copies the item first and then removes it from its current location.

The manpage of rename() says:

> Both old and new must be of the same type (that is, both must be either directories or non-directories) nondirectories) directories) and must reside on the same file system.

On the other hand, the documentation of NSFileManager.moveItemAtURL() says:

> If the source and destination of the move operation are not on the same volume, this method copies the item first and then removes it from its current location.
@ikesyo
Copy link
Member Author

ikesyo commented Aug 25, 2015

Originally moveItemAtURL() was replaced by rename() in 48e480d. Is going back to moveItemAtURL() acceptable, or should we try rename() at first then fall back to moveItemAtURL() when EXDEV error occurred?

/cc @jspahrsummers

@jashephe
Copy link

jashephe commented Sep 4, 2015

Hi — just wanted to check in: is NSFileManager.moveItemAtURL() an acceptable fix, or is there a reason why rename() has to be used?

@jspahrsummers
Copy link
Member

rename() is atomic, and also replaces the destination if need be.

NSFileManager offers neither of these guarantees, unfortunately.

@jspahrsummers
Copy link
Member

Checking for EXDEV is a good idea. 👍

@ikesyo ikesyo changed the title Use NSFileManager.moveItemAtURL() instead of rename() system call Use NSFileManager.moveItemAtURL() as a fallback of rename() system call when EXDEV error occurred Sep 8, 2015
@ikesyo
Copy link
Member Author

ikesyo commented Sep 8, 2015

Thank you for your inputs! 🙏 I've updated the PR.

@mdiep
Copy link
Member

mdiep commented Sep 9, 2015

Looks good to me!

mdiep added a commit that referenced this pull request Sep 9, 2015
Use NSFileManager.moveItemAtURL() as a fallback of rename() system call when EXDEV error occurred
@mdiep mdiep merged commit a074297 into master Sep 9, 2015
@mdiep mdiep deleted the not-rename-but-move branch September 9, 2015 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"cross-device link" error on carthage update for some sources
4 participants