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 TempDirCache to cache TempDir results, fixes #13 #15

Closed
wants to merge 1 commit into from

Conversation

twpayne
Copy link
Contributor

@twpayne twpayne commented Feb 3, 2019

This is an alternative solution to #13. Note that it shares some code (getDev) with #14 but addresses separate functionality.

This PR adds TempDirCache, which is an intelligent cache for TempDir. Temporary directories can be re-used for all destination directories on the same device.

It's not clear how to write an automated test for this, as you'd need either to mount a different filesystem (which the user running the test might not have privileges to do) or mock out os.Stat (hooks to do this aren't in place).

Instead, I've included internal/tempdircache_test which exercises the code. See the comment in internal/tempdircache_test/main.go for details, but you can see the cache in action on modern Linux systems with:

$ go run ./internal/tempdircache_test $XDG_RUNTIME_DIR $XDG_RUNTIME_DIR/systemd

@twpayne
Copy link
Contributor Author

twpayne commented Feb 3, 2019

Closing for now following discussion in #13.

@twpayne twpayne closed this Feb 3, 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.

1 participant