aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/actions/cache/Metadata.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/actions/cache/Metadata.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/cache/Metadata.java20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/actions/cache/Metadata.java b/src/main/java/com/google/devtools/build/lib/actions/cache/Metadata.java
index 642bd29593..c14cb03a57 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/cache/Metadata.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/cache/Metadata.java
@@ -14,12 +14,12 @@
package com.google.devtools.build.lib.actions.cache;
+import com.google.devtools.build.lib.actions.FileStateType;
+
/**
- * An interface to represent the state of a file (or directory). This is used to determine whether a
- * file has changed or not.
- *
- * <p>NB! Several other parts of Blaze are relying on the fact that metadata uses mtime and not
- * ctime. If metadata is ever changed to use ctime, all uses of Metadata must be carefully examined.
+ * An interface to represent the state of a file system object for the execution phase. This is not
+ * used by Skyframe for invalidation, it is primarily used by the action cache and the various
+ * {@link com.google.devtools.build.lib.exec.SpawnRunner} implementations.
*/
public interface Metadata {
/**
@@ -30,6 +30,14 @@ public interface Metadata {
}
/**
+ * The type of the underlying file system object. If it is a regular file, then it is
+ * guaranteed to have a digest. Otherwise it does not have a digest.
+ */
+ default FileStateType getType() {
+ return isFile() ? FileStateType.REGULAR_FILE : FileStateType.DIRECTORY;
+ }
+
+ /**
* Whether the underlying file system object is a file or a symlink to a file, rather than a
* directory. All files are guaranteed to have a digest, and {@link #getDigest} must only be
* called on files.
@@ -40,7 +48,7 @@ public interface Metadata {
* Returns the file's digest; must only be called on objects for which {@link #isFile} returns
* true.
*
- * <p>The return value is owned by the cache and must not be modified.
+ * <p>The return value is owned by this object and must not be modified.
*/
byte[] getDigest();