Fix caching of top-level items
This commit is contained in:
parent
ecbd6d5552
commit
52667388e9
@ -24,14 +24,16 @@ def trim_base_custom(path, base):
|
|||||||
return path
|
return path
|
||||||
def trim_base(path):
|
def trim_base(path):
|
||||||
return trim_base_custom(path, trim_base.base)
|
return trim_base_custom(path, trim_base.base)
|
||||||
def cache_base(path):
|
def cache_base(path, filepath=False):
|
||||||
|
if len(path) == 0:
|
||||||
|
return "root"
|
||||||
|
elif filepath and len(path.split(os.sep)) < 2:
|
||||||
|
path = "root-" + path
|
||||||
path = trim_base(path).replace('/', '-').replace(' ', '_').replace('(', '').replace('&', '').replace(',', '').replace(')', '').replace('#', '').replace('[', '').replace(']', '').replace('"', '').replace("'", '').replace('_-_', '-').lower()
|
path = trim_base(path).replace('/', '-').replace(' ', '_').replace('(', '').replace('&', '').replace(',', '').replace(')', '').replace('#', '').replace('[', '').replace(']', '').replace('"', '').replace("'", '').replace('_-_', '-').lower()
|
||||||
while path.find("--") != -1:
|
while path.find("--") != -1:
|
||||||
path = path.replace("--", "-")
|
path = path.replace("--", "-")
|
||||||
while path.find("__") != -1:
|
while path.find("__") != -1:
|
||||||
path = path.replace("__", "_")
|
path = path.replace("__", "_")
|
||||||
if len(path) == 0:
|
|
||||||
path = "root"
|
|
||||||
return path
|
return path
|
||||||
def json_cache(path):
|
def json_cache(path):
|
||||||
return cache_base(path) + ".json"
|
return cache_base(path) + ".json"
|
||||||
@ -40,6 +42,8 @@ def image_cache(path, size, square=False):
|
|||||||
suffix = str(size) + "s"
|
suffix = str(size) + "s"
|
||||||
else:
|
else:
|
||||||
suffix = str(size)
|
suffix = str(size)
|
||||||
return cache_base(path) + "_" + suffix + ".jpg"
|
return cache_base(path, True) + "_" + suffix + ".jpg"
|
||||||
|
def video_cache(path):
|
||||||
|
return cache_base(path, True) + ".webm"
|
||||||
def file_mtime(path):
|
def file_mtime(path):
|
||||||
return datetime.fromtimestamp(int(os.path.getmtime(path)))
|
return datetime.fromtimestamp(int(os.path.getmtime(path)))
|
||||||
|
@ -356,7 +356,7 @@ class Photo(object):
|
|||||||
os.unlink(tfn)
|
os.unlink(tfn)
|
||||||
|
|
||||||
def _video_transcode(self, transcode_path, original_path):
|
def _video_transcode(self, transcode_path, original_path):
|
||||||
transcode_path = os.path.join(transcode_path, cache_base(self._path) + '.webm')
|
transcode_path = os.path.join(transcode_path, video_cache(self._path))
|
||||||
transcode_cmd = ['-i', original_path, '-c:v', 'libvpx', '-crf', '10', '-b:v', '800k', '-c:a', 'libvorbis', '-f', 'webm', '-threads', '2', '-loglevel', '0', '-y']
|
transcode_cmd = ['-i', original_path, '-c:v', 'libvpx', '-crf', '10', '-b:v', '800k', '-c:a', 'libvorbis', '-f', 'webm', '-threads', '2', '-loglevel', '0', '-y']
|
||||||
filters = []
|
filters = []
|
||||||
info_string = "%s -> webm" % (os.path.basename(original_path))
|
info_string = "%s -> webm" % (os.path.basename(original_path))
|
||||||
@ -403,7 +403,7 @@ class Photo(object):
|
|||||||
for size in Photo.thumb_sizes:
|
for size in Photo.thumb_sizes:
|
||||||
if size[1]:
|
if size[1]:
|
||||||
caches.append(image_cache(self._path, size[0], size[1]))
|
caches.append(image_cache(self._path, size[0], size[1]))
|
||||||
caches.append(cache_base(self._path) + '.webm')
|
caches.append(video_cache(self._path))
|
||||||
else:
|
else:
|
||||||
caches = [image_cache(self._path, size[0], size[1]) for size in Photo.thumb_sizes]
|
caches = [image_cache(self._path, size[0], size[1]) for size in Photo.thumb_sizes]
|
||||||
return caches
|
return caches
|
||||||
|
Loading…
Reference in New Issue
Block a user