check for file name length in cache
This commit is contained in:
@@ -17,6 +17,7 @@ CACHE_DIR = Path(CACHE_DIR)
|
||||
ACCEPTED = re.compile(f"[^{string.ascii_letters}{string.digits}" r" \-_()\[\]\*~\.,=\+" "]")
|
||||
WHITESPACE = re.compile(r"\s+")
|
||||
PRECACHED = {}
|
||||
PATH_LEN = 250
|
||||
|
||||
Ts = TypeVarTuple("Ts")
|
||||
T = TypeVar("T")
|
||||
@@ -29,7 +30,10 @@ def sort_dict(value: Any) -> dict[str, Any]:
|
||||
|
||||
|
||||
def normalize_path(s: str) -> str:
|
||||
return ACCEPTED.sub("_", " ".join(WHITESPACE.split(s))).strip()
|
||||
path = ACCEPTED.sub("_", " ".join(WHITESPACE.split(s))).strip()
|
||||
if len(path) > PATH_LEN:
|
||||
path = hashlib.md5(path.encode()).hexdigest()
|
||||
return path
|
||||
|
||||
|
||||
class Cache:
|
||||
|
||||
Reference in New Issue
Block a user