utils: use schema mtime as cache key (#39153)
This commit is contained in:
parent
0d8b5bd8ef
commit
65f023086a
|
@ -41,17 +41,22 @@ def get_warehouses_paths():
|
|||
|
||||
|
||||
@lru_cache()
|
||||
def get_warehouse_by_path_and_mtime(path, mtime):
|
||||
warehouse = json.load(open(path))
|
||||
warehouse['path'] = path
|
||||
return Warehouse.from_json(warehouse)
|
||||
|
||||
|
||||
def get_warehouses_by_paths(paths):
|
||||
warehouses = []
|
||||
for path in paths:
|
||||
d = json.load(open(path))
|
||||
d['path'] = path
|
||||
warehouses.append(Warehouse.from_json(d))
|
||||
mtime = os.path.getmtime(path)
|
||||
warehouses.append(get_warehouse_by_path_and_mtime(path, mtime))
|
||||
return warehouses
|
||||
|
||||
|
||||
def get_warehouses():
|
||||
paths = frozenset(get_warehouses_paths())
|
||||
paths = get_warehouses_paths()
|
||||
return get_warehouses_by_paths(paths)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue