Projet

Général

Profil

0001-utils-use-schema-mtime-as-cache-key-39153.patch

Benjamin Dauvergne, 21 janvier 2020 23:08

Télécharger (1,14 ko)

Voir les différences:

Subject: [PATCH] utils: use schema mtime as cache key (#39153)

 bijoe/utils.py | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
bijoe/utils.py
41 41

  
42 42

  
43 43
@lru_cache()
44
def get_warehouse_by_path_and_mtime(path, mtime):
45
    warehouse = json.load(open(path))
46
    warehouse['path'] = path
47
    return Warehouse.from_json(warehouse)
48

  
49

  
44 50
def get_warehouses_by_paths(paths):
45 51
    warehouses = []
46 52
    for path in paths:
47
        d = json.load(open(path))
48
        d['path'] = path
49
        warehouses.append(Warehouse.from_json(d))
53
        mtime = os.path.getmtime(path)
54
        warehouses.append(get_warehouse_by_path_and_mtime(path, mtime))
50 55
    return warehouses
51 56

  
52 57

  
53 58
def get_warehouses():
54
    paths = frozenset(get_warehouses_paths())
59
    paths = get_warehouses_paths()
55 60
    return get_warehouses_by_paths(paths)
56 61

  
57 62

  
58
-