diff options
author | ccalvarin <ccalvarin@google.com> | 2018-07-23 18:16:18 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-07-23 18:18:36 -0700 |
commit | dd9f60e4d2721cdfd3044a8c8a1bdfd8e444009c (patch) | |
tree | 40d209283f1aec518fc57d7c07001a13bbabe1e3 /src/main/java/com/google/devtools/build/lib/vfs | |
parent | 69301af7fdf8be97627bddeb33224289ebe4de93 (diff) |
Remove redundancy in DigestHashFunction use in FileSystem.
Each FileSystem instance has a digest function, but the getDigest and getHashDigest functions also accepted their own custom parameter functions. We only support 1 hash per filesystem instance, these parameters are redundant.
RELNOTES: None.
PiperOrigin-RevId: 205758571
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/vfs')
3 files changed, 7 insertions, 38 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java b/src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java index 8258dccfc0..8d10e5800b 100644 --- a/src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java +++ b/src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java @@ -238,20 +238,11 @@ public abstract class FileSystem { * one available or the filesystem doesn't support them. This digest should be suitable for * detecting changes to the file. */ - protected byte[] getFastDigest(Path path, DigestHashFunction hashFunction) throws IOException { + protected byte[] getFastDigest(Path path) throws IOException { return null; } /** - * Gets a fast digest for the given path, or {@code null} if there isn't one available or the - * filesystem doesn't support them. This digest should be suitable for detecting changes to the - * file. - */ - protected final byte[] getFastDigest(Path path) throws IOException { - return getFastDigest(path, digestFunction); - } - - /** * Returns whether the given digest is a valid digest for the default digest function. */ public boolean isValidDigest(byte[] digest) { @@ -259,31 +250,20 @@ public abstract class FileSystem { } /** - * Returns the digest of the file denoted by the path, following symbolic links, for the given - * hash digest function. + * Returns the digest of the file denoted by the path, following symbolic links. * - * <p>Subclasses may (and do) optimize this computation for particular digest functions. + * <p>Subclasses may (and do) optimize this computation for a particular digest functions. * * @return a new byte array containing the file's digest * @throws IOException if the digest could not be computed for any reason */ - protected byte[] getDigest(final Path path, DigestHashFunction hashFunction) throws IOException { + protected byte[] getDigest(final Path path) throws IOException { return new ByteSource() { @Override public InputStream openStream() throws IOException { return getInputStream(path); } - }.hash(hashFunction.getHash()).asBytes(); - } - - /** - * Returns the digest of the file denoted by the path, following symbolic links. - * - * @return a new byte array containing the file's digest - * @throws IOException if the digest could not be computed for any reason - */ - protected final byte[] getDigest(final Path path) throws IOException { - return getDigest(path, digestFunction); + }.hash(digestFunction.getHash()).asBytes(); } /** diff --git a/src/main/java/com/google/devtools/build/lib/vfs/JavaIoFileSystem.java b/src/main/java/com/google/devtools/build/lib/vfs/JavaIoFileSystem.java index 25fafac67b..1fec03f5db 100644 --- a/src/main/java/com/google/devtools/build/lib/vfs/JavaIoFileSystem.java +++ b/src/main/java/com/google/devtools/build/lib/vfs/JavaIoFileSystem.java @@ -412,11 +412,11 @@ public class JavaIoFileSystem extends AbstractFileSystemWithCustomStat { } @Override - protected byte[] getDigest(Path path, DigestHashFunction hashFunction) throws IOException { + protected byte[] getDigest(Path path) throws IOException { String name = path.toString(); long startTime = Profiler.nanoTimeMaybe(); try { - return super.getDigest(path, hashFunction); + return super.getDigest(path); } finally { profiler.logSimpleTask(startTime, ProfilerTask.VFS_MD5, name); } diff --git a/src/main/java/com/google/devtools/build/lib/vfs/Path.java b/src/main/java/com/google/devtools/build/lib/vfs/Path.java index 7629f6cf1b..497b0bbd5d 100644 --- a/src/main/java/com/google/devtools/build/lib/vfs/Path.java +++ b/src/main/java/com/google/devtools/build/lib/vfs/Path.java @@ -825,17 +825,6 @@ public class Path } /** - * Returns the digest of the file denoted by the current path and digest function, following - * symbolic links. - * - * @return a new byte array containing the file's digest - * @throws IOException if the digest could not be computed for any reason - */ - public byte[] getDigest(DigestHashFunction hashFunction) throws IOException { - return fileSystem.getDigest(this, hashFunction); - } - - /** * Opens the file denoted by this path, following symbolic links, for reading, and returns an * input stream to it. * |