Skip to content

tmpfs: add temporal overlay filesystem #27

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

Merged
merged 1 commit into from
May 8, 2017

Conversation

ajnavarro
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Apr 27, 2017

Codecov Report

Merging #27 into master will decrease coverage by 1.84%.
The diff coverage is 78.2%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #27      +/-   ##
==========================================
- Coverage   90.27%   88.43%   -1.85%     
==========================================
  Files           6        7       +1     
  Lines         432      510      +78     
==========================================
+ Hits          390      451      +61     
- Misses         23       32       +9     
- Partials       19       27       +8
Impacted Files Coverage Δ
tmpoverlayfs/tmpfs.go 78.2% <78.2%> (ø)

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 99d8398...c8ef2d3. Read the comment docs.

utils.go Outdated
@@ -98,3 +98,31 @@ func WriteFile(fs Filesystem, filename string, data []byte, perm os.FileMode) er

return err
}

// CopyPath copies file across filesystems.
Copy link
Contributor

Choose a reason for hiding this comment

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

copies a file.

Copy link
Contributor

Choose a reason for hiding this comment

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

To be consistent with the rest of the utils, maybe this should be called CopyFile, although I would call it simply Copy.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we decided not to provide a CopyFile (or CopyPath) in the public API, since it is tricky to provide consistent behavior across implementations (see this). So we'll limit ourselves to functions that exist in the standard library (e.g. os) for which we can provide sane behavior. So this would be private.

tmpfs/tmpfs.go Outdated
type tmpFs struct {
fs billy.Filesystem
tmp billy.Filesystem
tempFiles map[string]bool
Copy link
Contributor

Choose a reason for hiding this comment

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

make this attribute a map[string]billy.Filesystem, call it resolver, add add a resolve method instead of isTempFile. This should make the code even simpler I believe.

Copy link
Contributor

Choose a reason for hiding this comment

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

That would be could, although I think we need to check explicitely if it's temp file or not to provide the functionality of copying it to fs in some cases, so it's not only about resolving Filsystem that should be accessed.

tmpfs/tmpfs.go Outdated
return t.fs.Rename(from, to)
}

func (t *tmpFs) Remove(path string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

should we remove the entry from the tmpFiles also? it is difficult to tell.

Copy link
Contributor

Choose a reason for hiding this comment

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

This should be documented somewhere in the original API of billy.

Copy link
Contributor

Choose a reason for hiding this comment

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

@alcortesm I think it's documented in the interface? In any case, it replicates os.Remove behavior.
👍 to remove it from tmpFiles map.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@smola
Copy link
Contributor

smola commented Apr 27, 2017

tmpfs might be a bit misleading name, since it's similar to Linux' tmpfs, but it's a different thing. On the other hand, tmpoverlayfs might be too long?

@alcortesm
Copy link
Contributor

Let's call it tmpRouter.

@smola
Copy link
Contributor

smola commented Apr 28, 2017

@alcortesm The convention is that fs names end with fs, so it's easy to tell os apart from osfs, other mem stuff from memfs, etc. Also, since it's a package name, it's all lowercase. So it might be tmprouterfs, although I find the router part a bit confusing for this case.

@alcortesm
Copy link
Contributor

On a second thought, yes, the router thing is quite misleading.

@bzz
Copy link

bzz commented May 4, 2017

Regarding naming, how about tmpdirfs?

tmpoverlayfs sounds better then tmpfs, but still may be a bit confusing, as may be persived as related to Docker's OverlayFS

Except for that - looks good to me.

return err
}

return t.tmp.Remove(from)
Copy link
Contributor

Choose a reason for hiding this comment

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

remove entry from tmp files map?

@smola
Copy link
Contributor

smola commented May 8, 2017

@ajnavarro Clean up history if needed.

- Added specific tests
- Each method call to the exact method of the underlying filesystems
- Added copyFile private logic
@ajnavarro ajnavarro force-pushed the feature/temp-overlay branch from 6587167 to c8ef2d3 Compare May 8, 2017 09:29
@ajnavarro
Copy link
Contributor Author

@smola done.

@ajnavarro ajnavarro merged commit cadb3c8 into src-d:master May 8, 2017
@ajnavarro ajnavarro deleted the feature/temp-overlay branch May 8, 2017 09:32
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