diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-10-28 07:44:11 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-10-28 07:44:11 +0100 |
commit | 88ed09858a36230223b59097f966d90cf9442a5a (patch) | |
tree | a1a8397adbfbf58741f5d24b9ee21a2d10918d5c | |
parent | modules: Update rsb (diff) | |
download | rtems-central-88ed09858a36230223b59097f966d90cf9442a5a.tar.bz2 |
items: Detect file removals in item cache
-rw-r--r-- | rtemsspec/items.py | 5 | ||||
-rw-r--r-- | rtemsspec/tests/test_items_itemcache.py | 4 |
2 files changed, 8 insertions, 1 deletions
diff --git a/rtemsspec/items.py b/rtemsspec/items.py index e9f1c0e2..d7f96a4d 100644 --- a/rtemsspec/items.py +++ b/rtemsspec/items.py @@ -576,10 +576,13 @@ class ItemCache: update_cache = False except FileNotFoundError: update_cache = True + else: + update_cache = mtime <= os.path.getmtime(path) for name in os.listdir(path): path2 = os.path.join(path, name) if name.endswith(".yml") and not name.startswith("."): - update_cache = update_cache or mtime <= os.path.getmtime(path2) + if not update_cache: + update_cache = mtime <= os.path.getmtime(path2) else: if stat.S_ISDIR(os.lstat(path2).st_mode): self._load_items_recursive(base, path2, cache_dir) diff --git a/rtemsspec/tests/test_items_itemcache.py b/rtemsspec/tests/test_items_itemcache.py index b2205864..0aaacb28 100644 --- a/rtemsspec/tests/test_items_itemcache.py +++ b/rtemsspec/tests/test_items_itemcache.py @@ -65,6 +65,10 @@ def test_load(tmpdir): assert item.uid == "/foo/bar" assert item.type == "" assert item["type"] == "spec" + os.remove(os.path.join(tmpdir, "spec", "d", "c.yml")) + item_cache_4 = ItemCache(config) + with pytest.raises(KeyError): + item_cache_4["/d/c"] def test_load_link_error(tmpdir): |