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

add RemoveAll #12

Merged
merged 5 commits into from
Feb 20, 2017
Merged

add RemoveAll #12

merged 5 commits into from
Feb 20, 2017

Conversation

smola
Copy link
Contributor

@smola smola commented Feb 14, 2017

  • This PR adds RemoveAll function, with native implementation for os and fallback for other filesystems.
    RemoveAll code is based on standard os.RemoveAll and has the same behavior.

  • Other fixes for Stat, ReadDir and Remove behavior with respect to directories.

@smola
Copy link
Contributor Author

smola commented Feb 15, 2017

Don't merge; there is something wrong with this PR.

Fixed

* memfs: fix Stat for directories: isDir now returns true for them.

* memfs: fix FileInfo Size for directories.

* test: added further tests for Stat on directories
RemoveAll delegates to filesystem's RemoveAll if it is implemented.
Otherwise, it falls back to a generic implementation.

Semantics are the same as os.RemoveAll.
@codecov-io
Copy link

codecov-io commented Feb 16, 2017

Codecov Report

Merging #12 into master will increase coverage by 2.02%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master      #12      +/-   ##
==========================================
+ Coverage   82.55%   84.58%   +2.02%     
==========================================
  Files           2        2              
  Lines         258      279      +21     
==========================================
+ Hits          213      236      +23     
+ Misses         29       28       -1     
+ Partials       16       15       -1
Impacted Files Coverage Δ
memfs/memory.go 87.17% <100%> (+2.43%)
osfs/os.go 78.57% <100%> (+0.79%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f84fa56...3d9b579. Read the comment docs.

memfs/memory.go Outdated
}

if p == "." || p == ".." {
return false
Copy link
Contributor

Choose a reason for hiding this comment

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

You can test this easily.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well, I haven't found any case where this can be reproduced from public methods...

memfs/memory.go Outdated
func isInDir(dir, path string) bool {
p, err := filepath.Rel(dir, path)
if err != nil {
return false
Copy link
Contributor

Choose a reason for hiding this comment

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

You can test it easily creating a path that cannot be relative from dir.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the only way to reproduce that (from public methods) is using Windows paths :s

@smola smola mentioned this pull request Feb 16, 2017
* test: add test passing a relative path to RemoveAll.

* memfs: simplify isInDir code using path package.
@mcuadros mcuadros merged commit 9c1722d into src-d:master Feb 20, 2017
@smola smola deleted the removeall branch February 20, 2017 12:36
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.

6 participants