From 8df3747348989b82d7e360dc202da2fcbcd4f8cb Mon Sep 17 00:00:00 2001 From: felly Date: Mon, 11 Jun 2018 10:20:28 -0700 Subject: Consolidate filesystem metadata operations in ActionFS by extending AbstractFileSystemWithCustomStat. RELNOTES: None PiperOrigin-RevId: 200071031 --- .../build/lib/skyframe/ActionFileSystem.java | 37 ++++------------------ 1 file changed, 7 insertions(+), 30 deletions(-) (limited to 'src/main/java/com/google/devtools/build') diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java index 6fe598d282..757c310697 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java @@ -36,6 +36,7 @@ import com.google.devtools.build.lib.actions.MetadataProvider; import com.google.devtools.build.lib.profiler.Profiler; import com.google.devtools.build.lib.profiler.ProfilerTask; import com.google.devtools.build.lib.profiler.SilentCloseable; +import com.google.devtools.build.lib.vfs.AbstractFileSystemWithCustomStat; import com.google.devtools.build.lib.vfs.FileStatus; import com.google.devtools.build.lib.vfs.FileSystem; import com.google.devtools.build.lib.vfs.Path; @@ -51,7 +52,6 @@ import java.io.InterruptedIOException; import java.io.OutputStream; import java.util.Collection; import java.util.HashMap; -import java.util.logging.Logger; import javax.annotation.Nullable; /** @@ -65,9 +65,9 @@ import javax.annotation.Nullable; * access {@link env}, they must also used synchronized access. * */ -final class ActionFileSystem extends FileSystem implements MetadataProvider, InjectionListener { - private static final Logger LOGGER = Logger.getLogger(ActionFileSystem.class.getName()); - public static final BaseEncoding LOWER_CASE_HEX = BaseEncoding.base16().lowerCase(); +final class ActionFileSystem extends AbstractFileSystemWithCustomStat + implements MetadataProvider, InjectionListener { + private static final BaseEncoding LOWER_CASE_HEX = BaseEncoding.base16().lowerCase(); /** Actual underlying filesystem. */ private final FileSystem delegate; @@ -214,11 +214,14 @@ final class ActionFileSystem extends FileSystem implements MetadataProvider, Inj @Override public boolean isDirectory() { + // TODO(felly): Support directory awareness. return false; } @Override public boolean isSymbolicLink() { + // TODO(felly): We should have minimal support for symlink awareness when looking at + // output --> src and src --> src symlinks. return false; } @@ -305,38 +308,12 @@ final class ActionFileSystem extends FileSystem implements MetadataProvider, Inj return getMetadataOrThrowFileNotFound(path).getDigest(); } - @Override - protected boolean isSymbolicLink(Path path) { - // TODO(felly): We should have minimal support for symlink awareness when looking at - // output --> src and src --> src symlinks. - return false; - } - - @Override - protected boolean isDirectory(Path path, boolean followSymlinks) { - // TODO(felly): Support directory awareness. - return true; - } - @Override protected Collection getDirectoryEntries(Path path) throws IOException { // TODO(felly): Support directory traversal. return ImmutableList.of(); } - @Override - protected boolean isFile(Path path, boolean followSymlinks) { - // TODO(felly): Unify is* methods with the stat() operation. - FileArtifactValue metadata = getMetadataUnchecked(path); - return metadata == null ? false : metadata.getType() == FileStateType.REGULAR_FILE; - } - - @Override - protected boolean isSpecialFile(Path path, boolean followSymlinks) { - FileArtifactValue metadata = getMetadataUnchecked(path); - return metadata == null ? false : metadata.getType() == FileStateType.SPECIAL_FILE; - } - private static String createSymbolicLinkErrorMessage( Path linkPath, PathFragment targetFragment, String message) { return "createSymbolicLink(" + linkPath + ", " + targetFragment + "): " + message; -- cgit v1.2.3