Commits

Felix Krull committed 4d0b366 Merge

Merge branch 'master' into build-changes

Comments (0)

Files changed (1)

scanner/CachePath.py

 	return path
 def trim_base(path):
 	return trim_base_custom(path, trim_base.base)
-def cache_base(path):
+def cache_base(path, ensure_has_directory_prefix=False):
 	path = trim_base(path)
-	seps = path.count(os.sep)
-	if seps == 0 and len(path) > 0:
-		path = "root-%s" % path
+	if ensure_has_directory_prefix:
+		seps = path.count(os.sep)
+		if seps == 0 and len(path) > 0:
+			path = "root-%s" % path
 	path = path.replace(os.sep, '-').replace(' ', '_').replace('(', '').replace('&', '').replace(',', '').replace(')', '').replace('#', '').replace('[', '').replace(']', '').replace('"', '').replace("'", '').replace('_-_', '-').lower()
 	while path.find("--") != -1:
 		path = path.replace("--", "-")
 		suffix = str(size) + "s"
 	else:
 		suffix = str(size)
-	return cache_base(path) + "_" + suffix + ".jpg"
+	return cache_base(path, ensure_has_directory_prefix=True) + "_" + suffix + ".jpg"
 def file_mtime(path):
 	return datetime.fromtimestamp(int(os.path.getmtime(path)))