diff options
author | janakr <janakr@google.com> | 2018-01-16 14:15:09 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-01-16 14:23:31 -0800 |
commit | 8b0934795036154dd4d835ea30770bc0b86243a9 (patch) | |
tree | 1ca728b45ef0898299ec0562ab53887091bb5768 /src/main/java/com | |
parent | 53e45318ad8da0a244639a44c1c9a1720d8c4b10 (diff) |
Remove mtime field from FileStateValue.
We stopped treating empty files specially in the execution phase after unknown commit. So this code is mostly if not entirely orphaned. The only scenario in which this would lead to a semantic difference that I can think of is if the user is running with --nouse_action_cache and a running Bazel server, and they have an action they want to re-run when an empty input file changes, which isn't something we need to be concerned about.
PiperOrigin-RevId: 182109952
Diffstat (limited to 'src/main/java/com')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skyframe/FileStateValue.java | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/FileStateValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/FileStateValue.java index 2595663fd4..7a3453a243 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/FileStateValue.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/FileStateValue.java @@ -133,19 +133,12 @@ public abstract class FileStateValue implements SkyValue { @ThreadSafe public static final class RegularFileStateValue extends FileStateValue { private final long size; - // Only needed for empty-file equality-checking. Otherwise is always -1. - // TODO(bazel-team): Consider getting rid of this special case for empty files. - private final long mtime; @Nullable private final byte[] digest; @Nullable private final FileContentsProxy contentsProxy; - public RegularFileStateValue(long size, long mtime, byte[] digest, - FileContentsProxy contentsProxy) { + public RegularFileStateValue(long size, byte[] digest, FileContentsProxy contentsProxy) { Preconditions.checkState((digest == null) != (contentsProxy == null)); this.size = size; - // mtime is forced to be -1 so that we do not accidentally depend on it for non-empty files, - // which should only be compared using digests. - this.mtime = size == 0 ? mtime : -1; this.digest = digest; this.contentsProxy = contentsProxy; } @@ -168,13 +161,12 @@ public abstract class FileStateValue implements SkyValue { if (tsgm != null) { tsgm.notifyDependenceOnFileTime(path.asFragment(), mtime); } - return new RegularFileStateValue(stat.getSize(), stat.getLastModifiedTime(), null, - FileContentsProxy.create(stat)); + return new RegularFileStateValue(stat.getSize(), null, FileContentsProxy.create(stat)); } else { // We are careful here to avoid putting the value ID into FileMetadata if we already have // a digest. Arbitrary filesystems may do weird things with the value ID; a digest is more // robust. - return new RegularFileStateValue(stat.getSize(), stat.getLastModifiedTime(), digest, null); + return new RegularFileStateValue(stat.getSize(), digest, null); } } catch (IOException e) { String errorMessage = e.getMessage() != null @@ -208,10 +200,6 @@ public abstract class FileStateValue implements SkyValue { return size; } - public long getMtime() { - return mtime; - } - @Override @Nullable public byte[] getDigest() { @@ -232,14 +220,13 @@ public abstract class FileStateValue implements SkyValue { } RegularFileStateValue other = (RegularFileStateValue) obj; return size == other.size - && mtime == other.mtime && Arrays.equals(digest, other.digest) && Objects.equals(contentsProxy, other.contentsProxy); } @Override public int hashCode() { - return Objects.hash(size, mtime, Arrays.hashCode(digest), contentsProxy); + return Objects.hash(size, Arrays.hashCode(digest), contentsProxy); } @Override @@ -247,7 +234,6 @@ public abstract class FileStateValue implements SkyValue { return MoreObjects.toStringHelper(this) .add("digest", digest) .add("size", size) - .add("mtime", mtime) .add("contentsProxy", contentsProxy).toString(); } @@ -256,8 +242,7 @@ public abstract class FileStateValue implements SkyValue { String contents = digest != null ? String.format("digest of %s", Arrays.toString(digest)) : contentsProxy.prettyPrint(); - String extra = mtime != -1 ? String.format(" and mtime of %d", mtime) : ""; - return String.format("regular file with size of %d and %s%s", size, contents, extra); + return String.format("regular file with size of %d and %s", size, contents); } } |