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

feat(Filesystem): Add move implementation #1624

Merged
merged 10 commits into from
Jun 20, 2019

Conversation

27pchrisl
Copy link
Contributor

Implementation for all platforms, and uses the same move semantics across all.
It also preserves mtime across all platforms for both files and directories, (ctime is not available in some platforms, or is inconsistently handled by the underlying filesystem).
Moving a file to a directory does not imply moving it into that directory (ie "mv " does not imply "mv /" and will fail

Missing arguments -> fails
Move into a subdirectory of itself -> fails
Move a file to an nonexistent location -> fails
Move a file to "overwrite" a directory -> fails
Move a file into a nonexistent directory -> fails
Move a nonexistent file -> fails
Move a file into a subdirectory that is a file -> fails

Move a file onto itself -> succeeds (with no on-disk change)
Move a file into a directory -> succeeds
Move an empty directory into a directory -> succeeds
Move a file to overwrite an existing file -> succeeds (same as writeFile)
Move a directory tree into a directory -> succeeds
Move a directory tree out of a directory -> succeeds

@27pchrisl
Copy link
Contributor Author

This also merges in other dependent branches, as those changes are needed for this branch to work correctly.

@mlynch
Copy link
Contributor

mlynch commented Jun 6, 2019

Thanks! Given that we're trying to follow node's API for fs, should we call this rename instead?

@27pchrisl
Copy link
Contributor Author

Thanks! Given that we're trying to follow node's API for fs, should we call this rename instead?

Sure thing, I have changed it.

Copy link
Member

@jcesarmobile jcesarmobile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

The only concern I have is that it doesn't allow to move to a different directory type (i.e. from FilesystemDirectory.Documents to FilesystemDirectory.Data), just inside the same type.
But that can be improved in a future release.

@jcesarmobile jcesarmobile changed the title Filesystem.move implementation feat(Filesystem): Add move implementation Jun 20, 2019
@jcesarmobile jcesarmobile merged commit d0a18bf into ionic-team:master Jun 20, 2019
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.

4 participants