Show More
@@ -51,30 +51,38 b' def link(src, dest):' | |||
|
51 | 51 | os.chmod(dest, os.stat(src).st_mode) |
|
52 | 52 | |
|
53 | 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 | 65 | path = ui.configpath(longname, 'usercache', None) |
|
55 | 66 | if path: |
|
56 | path = os.path.join(path, hash) | |
|
67 | return path | |
|
68 | if os.name == 'nt': | |
|
69 | appdata = os.getenv('LOCALAPPDATA', os.getenv('APPDATA')) | |
|
70 | if appdata: | |
|
71 | return os.path.join(appdata, longname) | |
|
72 | elif platform.system() == 'Darwin': | |
|
73 | home = os.getenv('HOME') | |
|
74 | if home: | |
|
75 | return os.path.join(home, 'Library', 'Caches', longname) | |
|
76 | elif os.name == 'posix': | |
|
77 | path = os.getenv('XDG_CACHE_HOME') | |
|
78 | if path: | |
|
79 | return os.path.join(path, longname) | |
|
80 | home = os.getenv('HOME') | |
|
81 | if home: | |
|
82 | return os.path.join(home, '.cache', longname) | |
|
57 | 83 | else: |
|
58 | if os.name == 'nt': | |
|
59 | appdata = os.getenv('LOCALAPPDATA', os.getenv('APPDATA')) | |
|
60 | if appdata: | |
|
61 | path = os.path.join(appdata, longname, hash) | |
|
62 | elif platform.system() == 'Darwin': | |
|
63 | home = os.getenv('HOME') | |
|
64 | if home: | |
|
65 | path = os.path.join(home, 'Library', 'Caches', | |
|
66 | longname, hash) | |
|
67 | elif os.name == 'posix': | |
|
68 | path = os.getenv('XDG_CACHE_HOME') | |
|
69 | if path: | |
|
70 | path = os.path.join(path, longname, hash) | |
|
71 | else: | |
|
72 | home = os.getenv('HOME') | |
|
73 | if home: | |
|
74 | path = os.path.join(home, '.cache', longname, hash) | |
|
75 | else: | |
|
76 | raise error.Abort(_('unknown operating system: %s\n') % os.name) | |
|
77 | return path | |
|
84 | raise error.Abort(_('unknown operating system: %s\n') % os.name) | |
|
85 | return None | |
|
78 | 86 | |
|
79 | 87 | def inusercache(ui, hash): |
|
80 | 88 | path = usercachepath(ui, hash) |
General Comments 0
You need to be logged in to leave comments.
Login now