You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ro...@apache.org on 2020/12/29 13:30:45 UTC

[buildstream] 01/03: artifactcache.py: check that artifacts are complete and update file mtimes

This is an automated email from the ASF dual-hosted git repository.

root pushed a commit to branch abderrahim/cleanup-speedup
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit bd6f8fda224c956d2549626863b382605cc94898
Author: Abderrahim Kitouni <ak...@gnome.org>
AuthorDate: Sat Sep 12 11:43:05 2020 +0100

    artifactcache.py: check that artifacts are complete and update file mtimes
    
    This allows bst to recover from deleted files in the CAS cache such as the
    cleanup procedure done by bst2
---
 buildstream/_artifactcache/artifactcache.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py
index 38500a0..24fdbe8 100644
--- a/buildstream/_artifactcache/artifactcache.py
+++ b/buildstream/_artifactcache/artifactcache.py
@@ -561,7 +561,16 @@ class ArtifactCache():
     def contains(self, element, key):
         ref = self.get_artifact_fullname(element, key)
 
-        return self.cas.contains(ref)
+        if not self.cas.contains(ref):
+            return False
+
+        try:
+            tree = self.cas.resolve_ref(ref, update_mtime=True)
+            self.cas.update_tree_mtime(tree)
+            return True
+        except (CASError, FileNotFoundError):
+            self.remove(ref)
+            return False
 
     # list_artifacts():
     #