Skip to contentSkip to conversation

scripts/clean_functional_cache: tolerate missing .stamp files

PATCH In review Brian Cain 3 participants 3 messages Oct 27

lore
Share & tools
lore

Brian Cain

author
#0 lore raw

PATCH 1/1 scripts/clean_functional_cache: tolerate missing .stamp files

Assets cached before the stamp files were introduced have no corresponding .stamp file. The script already copes with that when reading the timestamp, by assuming the QEMU v10.1 release date, which makes such assets eligible for removal.

However, since commit c1bb594fe41, removing the asset also unconditionally unlinks its .stamp file. For these old entries that file does not exist, so unlink() raises FileNotFoundError and the script aborts after deleting the first such asset, leaving the rest of the cache uncleaned and returning an error.

Pass missing_ok=True so that a missing .stamp file is not an error.

Fixes c1bb594fe415 ("scripts/clean_functional_cache: Remove also .stamp files")
---
 scripts/clean_functional_cache.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/clean_functional_cache.py +1 -1
index 1ff98c7606d..30633069c8f 100755
@@ -44,4 +44,4 @@
         print(f"Removing {cache_dir}/{file.name}.")
         file.chmod(stat.S_IWRITE)
         file.unlink()
-        stampfile.unlink()
+        stampfile.unlink(missing_ok=True)
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 24 lines · Brian Cain

Assets cached before the stamp files were introduced have no corresponding .stamp file. The script already copes with that when reading the timestamp, by assuming the QEMU v10.1 release date, which makes such assets eligible for removal.

However, since commit c1bb594fe41, removing the asset also unconditionally unlinks its .stamp file. For these old entries that file does not exist, so unlink() raises FileNotFoundError and the script aborts after deleting the first such asset, leaving the rest of the cache uncleaned and returning an error.

Pass missing_ok=True so that a missing .stamp file is not an error.

Fixes c1bb594fe415 ("scripts/clean_functional_cache: Remove also .stamp files")
---
  scripts/clean_functional_cache.py | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
scripts/clean_functional_cache.py +0 -0
index 1ff98c7606d..30633069c8f 100755

scripts/clean_functional_cache.py line 47

Quoted 5 lines
scripts/clean_functional_cache.py +1 -1
@@ -44,4 +44,4 @@
          print(f"Removing {cache_dir}/{file.name}.")
          file.chmod(stat.S_IWRITE)
          file.unlink()
-        stampfile.unlink()
+        stampfile.unlink(missing_ok=True)
Reviewed-by on v1 1/1
#2 lore raw
In reply to Brian Cain
Quoted 11 lines · Brian Cain

Assets cached before the stamp files were introduced have no corresponding .stamp file. The script already copes with that when reading the timestamp, by assuming the QEMU v10.1 release date, which makes such assets eligible for removal.

However, since commit c1bb594fe41, removing the asset also unconditionally unlinks its .stamp file. For these old entries that file does not exist, so unlink() raises FileNotFoundError and the script aborts after deleting the first such asset, leaving the rest of the cache uncleaned and returning an error.

Quoted 7 lines

Pass missing_ok=True so that a missing .stamp file is not an error.

Fixes c1bb594fe415 ("scripts/clean_functional_cache: Remove also .stamp files")
---
  scripts/clean_functional_cache.py | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)