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

cache: OS-specific cache directories #1287

Merged
merged 1 commit into from
Sep 29, 2017
Merged

cache: OS-specific cache directories #1287

merged 1 commit into from
Sep 29, 2017

Conversation

prattmic
Copy link
Contributor

Note: I haven't had a chance to test this on Windows yet, and I don't have an OS X machine.

Windows, and to a lesser extent OS X, don't conform to XDG and have
their own preferred locations for caches.

On Windows, use %LOCALAPPDATA%/restic (i.e., ~/AppData/Local/restic). I
can't find authoritative documentation from Microsoft recommending
specifically which of %APPDATA%, %LOCALAPPDATA%, and %TEMP% should be
used for caches, but %LOCALAPPDATA% is where browsers store their
caches, so it seems like a good fit.

On OS X, use ~/Library/Caches/restic, which is recommended by the Apple
documentation. They do suggest using the application "bundle identifier"
as the base folder name, but restic doesn't have one, so I just used
"restic".

Windows, and to a lesser extent OS X, don't conform to XDG and have
their own preferred locations for caches.

On Windows, use %LOCALAPPDATA%/restic (i.e., ~/AppData/Local/restic). I
can't find authoritative documentation from Microsoft recommending
specifically which of %APPDATA%, %LOCALAPPDATA%, and %TEMP% should be
used for caches, but %LOCALAPPDATA% is where browsers store their
caches, so it seems like a good fit.

On OS X, use ~/Library/Caches/restic, which is recommended by the Apple
documentation. They do suggest using the application "bundle identifier"
as the base folder name, but restic doesn't have one, so I just used
"restic".
@codecov-io
Copy link

codecov-io commented Sep 28, 2017

Codecov Report

Merging #1287 into master will decrease coverage by 5.64%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1287      +/-   ##
=========================================
- Coverage   52.25%   46.6%   -5.65%     
=========================================
  Files         134     134              
  Lines       13016   13039      +23     
=========================================
- Hits         6801    6077     -724     
- Misses       5384    6186     +802     
+ Partials      831     776      -55
Impacted Files Coverage Δ
internal/cache/cache.go 29.87% <0%> (ø) ⬆️
internal/cache/dir.go 0% <0%> (ø) ⬆️
internal/backend/b2/b2.go 0% <0%> (-79.93%) ⬇️
internal/backend/azure/azure.go 0% <0%> (-75.35%) ⬇️
internal/backend/swift/swift.go 0% <0%> (-73.9%) ⬇️
internal/backend/gs/gs.go 0% <0%> (-65.6%) ⬇️
internal/backend/swift/config.go 34.37% <0%> (-56.25%) ⬇️
internal/archiver/archiver.go 65.2% <0%> (-0.17%) ⬇️

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 1ee1559...2133869. Read the comment docs.

@dionorgua
Copy link
Contributor

Just small note.

%LOCALAPPDATA% is probably correct choose. The real difference is that in corporate environment %APPDATA% will be roamed when user sign to different machine (Sign in on PC1, store something in %APPDATA%, logout. Go to PC2 and sign in with same domain account. %APPDATA% will be synchronized).

The only thing I'm wondering is that %LOCALAPPDATA%/restic is subject to backup by other apps. Ideally restic should explicitly tell system that this directory has no important data by creating special registry key in FilesNotToBackup tree: https://msdn.microsoft.com/en-us/library/windows/desktop/bb891959(v=vs.85).aspx

@prattmic
Copy link
Contributor Author

I can report that this works swimmingly on my Windows machine.

@dionorgua good to know thanks. Setting that registry key would be clever, but I think that is outside the scope of this PR.

Copy link
Member

@fd0 fd0 left a comment

Choose a reason for hiding this comment

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

LGTM!

@fd0 fd0 merged commit 2133869 into restic:master Sep 29, 2017
fd0 added a commit that referenced this pull request Sep 29, 2017
cache: OS-specific cache directories
@rawtaz
Copy link
Contributor

rawtaz commented Sep 29, 2017

Confirmed working on macOS 10.12.6.

@fd0
Copy link
Member

fd0 commented Sep 29, 2017

Thank you very much for the confirmation. This change is better done sooner rather than later, while the number of people affected (in terms of "have an unused cache lying around") is small.

Thanks everyone!

fd0 pushed a commit to prattmic/restic that referenced this pull request Oct 3, 2017
PR restic#1287 changed the default cache location on darwin and windows.
Update the changelog and manual to reflect the new behavior.

Since the cache hasn't been included in an official release yet, I've
just changed the main cache changelog entry.

Fixes restic#1309
@c0bw3b c0bw3b mentioned this pull request Nov 19, 2018
9 tasks
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.

5 participants