fix(conf): don't use cache dir as base for all data dirs

This is a bit tricky but the issue is that in a `for` loop, the loop
variable(s) are shared during the whole iteration. So capturing its
value in the `lambda` as `k=k` doesn't capture the value of the current
iteration, but the value of the last one.
In this code that happened to be `cache`, so all `data_dirs` usage was
ending up with a path under `directory_cache`.
This commit is contained in:
ThinkChaos 2024-02-05 21:29:45 -05:00
parent a816147e2e
commit efd7838b02
No known key found for this signature in database

View File

@ -332,12 +332,14 @@ for identifier,path in data_directories.items():
print("Make sure Maloja has write and execute access to this directory.")
raise
class DataDirs:
def __init__(self, dirs):
self.dirs = dirs
data_dir = {
k:lambda *x,k=k: pthj(data_directories[k],*x) for k in data_directories
}
def __getitem__(self, key):
return lambda *x, k=key: pthj(self.dirs[k], *x)
data_dir = DataDirs(data_directories)
### DOREAH OBJECTS