Skip to content
Snippets Groups Projects
Commit be4481d6222e authored by Matt Harbison's avatar Matt Harbison
Browse files

largefiles: refactor _usercachedir() to allow reuse with lfs

Largefiles puts everything into a flat directory, while lfs divides files up by
creating subdirectories consisting of the first two characters of the hash.
Therefore, pointing at the largefiles cache won't work.
parent 0768708589ef
No related branches found
No related tags found
No related merge requests found
......@@ -69,5 +69,5 @@
to preserve download bandwidth and storage space.'''
return os.path.join(_usercachedir(ui), hash)
def _usercachedir(ui):
def _usercachedir(ui, name=longname):
'''Return the location of the "global" largefiles cache.'''
......@@ -73,8 +73,8 @@
'''Return the location of the "global" largefiles cache.'''
path = ui.configpath(longname, 'usercache')
path = ui.configpath(name, 'usercache')
if path:
return path
if pycompat.iswindows:
appdata = encoding.environ.get('LOCALAPPDATA',\
encoding.environ.get('APPDATA'))
if appdata:
......@@ -75,10 +75,10 @@
if path:
return path
if pycompat.iswindows:
appdata = encoding.environ.get('LOCALAPPDATA',\
encoding.environ.get('APPDATA'))
if appdata:
return os.path.join(appdata, longname)
return os.path.join(appdata, name)
elif pycompat.isdarwin:
home = encoding.environ.get('HOME')
if home:
......@@ -82,7 +82,7 @@
elif pycompat.isdarwin:
home = encoding.environ.get('HOME')
if home:
return os.path.join(home, 'Library', 'Caches', longname)
return os.path.join(home, 'Library', 'Caches', name)
elif pycompat.isposix:
path = encoding.environ.get('XDG_CACHE_HOME')
if path:
......@@ -86,6 +86,6 @@
elif pycompat.isposix:
path = encoding.environ.get('XDG_CACHE_HOME')
if path:
return os.path.join(path, longname)
return os.path.join(path, name)
home = encoding.environ.get('HOME')
if home:
......@@ -90,6 +90,6 @@
home = encoding.environ.get('HOME')
if home:
return os.path.join(home, '.cache', longname)
return os.path.join(home, '.cache', name)
else:
raise error.Abort(_('unknown operating system: %s\n')
% pycompat.osname)
......@@ -93,7 +93,7 @@
else:
raise error.Abort(_('unknown operating system: %s\n')
% pycompat.osname)
raise error.Abort(_('unknown %s usercache location') % longname)
raise error.Abort(_('unknown %s usercache location') % name)
def inusercache(ui, hash):
path = usercachepath(ui, hash)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment