Consolidate filesystem metadata operations in ActionFS by extending AbstractFileSystemWithCustomStat.
RELNOTES: None
@@ -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.
* </ul>
*/
-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<String> 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;
