Show More
@@ -51,30 +51,38 b' def link(src, dest):' | |||||
51 | os.chmod(dest, os.stat(src).st_mode) |
|
51 | os.chmod(dest, os.stat(src).st_mode) | |
52 |
|
52 | |||
53 | def usercachepath(ui, hash): |
|
53 | def usercachepath(ui, hash): | |
|
54 | '''Return the correct location in the "global" largefiles cache for a file | |||
|
55 | with the given hash. | |||
|
56 | This cache is used for sharing of largefiles across repositories - both | |||
|
57 | to preserve download bandwidth and storage space.''' | |||
|
58 | path = _usercachedir(ui) | |||
|
59 | if path: | |||
|
60 | return os.path.join(path, hash) | |||
|
61 | return None | |||
|
62 | ||||
|
63 | def _usercachedir(ui): | |||
|
64 | '''Return the location of the "global" largefiles cache.''' | |||
54 | path = ui.configpath(longname, 'usercache', None) |
|
65 | path = ui.configpath(longname, 'usercache', None) | |
55 | if path: |
|
66 | if path: | |
56 | path = os.path.join(path, hash) |
|
67 | return path | |
57 | else: |
|
|||
58 |
|
|
68 | if os.name == 'nt': | |
59 |
|
|
69 | appdata = os.getenv('LOCALAPPDATA', os.getenv('APPDATA')) | |
60 |
|
|
70 | if appdata: | |
61 |
|
|
71 | return os.path.join(appdata, longname) | |
62 |
|
|
72 | elif platform.system() == 'Darwin': | |
63 |
|
|
73 | home = os.getenv('HOME') | |
64 |
|
|
74 | if home: | |
65 |
|
|
75 | return os.path.join(home, 'Library', 'Caches', longname) | |
66 | longname, hash) |
|
|||
67 |
|
|
76 | elif os.name == 'posix': | |
68 |
|
|
77 | path = os.getenv('XDG_CACHE_HOME') | |
69 |
|
|
78 | if path: | |
70 |
|
|
79 | return os.path.join(path, longname) | |
71 | else: |
|
|||
72 |
|
|
80 | home = os.getenv('HOME') | |
73 |
|
|
81 | if home: | |
74 |
|
|
82 | return os.path.join(home, '.cache', longname) | |
75 |
|
|
83 | else: | |
76 |
|
|
84 | raise error.Abort(_('unknown operating system: %s\n') % os.name) | |
77 |
return |
|
85 | return None | |
78 |
|
86 | |||
79 | def inusercache(ui, hash): |
|
87 | def inusercache(ui, hash): | |
80 | path = usercachepath(ui, hash) |
|
88 | path = usercachepath(ui, hash) |
General Comments 0
You need to be logged in to leave comments.
Login now