use of com.google.devtools.build.lib.skyframe.InconsistentFilesystemException in project bazel by bazelbuild.
the class AndroidSdkRepositoryFunction method getSubdirectoryListingValues.
/** Gets DirectoryListingValues for subdirectories of the directory or returns null. */
private static ImmutableMap<PathFragment, DirectoryListingValue> getSubdirectoryListingValues(final Path root, final PathFragment path, DirectoryListingValue directory, Environment env) throws RepositoryFunctionException, InterruptedException {
Map<PathFragment, SkyKey> skyKeysForSubdirectoryLookups = Maps.transformEntries(Maps.uniqueIndex(directory.getDirents(), new Function<Dirent, PathFragment>() {
@Override
public PathFragment apply(Dirent input) {
return path.getRelative(input.getName());
}
}), new EntryTransformer<PathFragment, Dirent, SkyKey>() {
@Override
public SkyKey transformEntry(PathFragment key, Dirent value) {
return DirectoryListingValue.key(RootedPath.toRootedPath(root, root.getRelative(key)));
}
});
Map<SkyKey, ValueOrException<InconsistentFilesystemException>> values = env.getValuesOrThrow(skyKeysForSubdirectoryLookups.values(), InconsistentFilesystemException.class);
ImmutableMap.Builder<PathFragment, DirectoryListingValue> directoryListingValues = new ImmutableMap.Builder<>();
for (PathFragment pathFragment : skyKeysForSubdirectoryLookups.keySet()) {
try {
SkyValue skyValue = values.get(skyKeysForSubdirectoryLookups.get(pathFragment)).get();
if (skyValue == null) {
return null;
}
directoryListingValues.put(pathFragment, (DirectoryListingValue) skyValue);
} catch (InconsistentFilesystemException e) {
throw new RepositoryFunctionException(new IOException(e), Transience.PERSISTENT);
}
}
return directoryListingValues.build();
}
use of com.google.devtools.build.lib.skyframe.InconsistentFilesystemException in project bazel by bazelbuild.
the class SkylarkRepositoryContext method verifyLabelMarkerData.
private static boolean verifyLabelMarkerData(String key, String value, Environment env) throws InterruptedException {
Preconditions.checkArgument(key.startsWith("FILE:"));
try {
Label label = Label.parseAbsolute(key.substring(5));
RootedPath rootedPath = getRootedPathFromLabel(label, env);
SkyKey fileSkyKey = FileValue.key(rootedPath);
FileValue fileValue = (FileValue) env.getValueOrThrow(fileSkyKey, IOException.class, FileSymlinkException.class, InconsistentFilesystemException.class);
if (fileValue == null || !fileValue.isFile()) {
return false;
}
return Objects.equals(value, Integer.toString(fileValue.realFileStateValue().hashCode()));
} catch (LabelSyntaxException e) {
throw new IllegalStateException("Key " + key + " is not a correct file key (should be in form FILE:label)", e);
} catch (IOException | FileSymlinkException | InconsistentFilesystemException | EvalException e) {
// Consider those exception to be a cause for invalidation
return false;
}
}
use of com.google.devtools.build.lib.skyframe.InconsistentFilesystemException in project bazel by bazelbuild.
the class RepositoryFunction method getRepositoryDirectory.
/**
* Adds the repository's directory to the graph and, if it's a symlink, resolves it to an actual
* directory.
*/
@Nullable
protected static FileValue getRepositoryDirectory(Path repositoryDirectory, Environment env) throws RepositoryFunctionException, InterruptedException {
SkyKey outputDirectoryKey = FileValue.key(RootedPath.toRootedPath(repositoryDirectory, PathFragment.EMPTY_FRAGMENT));
FileValue value;
try {
value = (FileValue) env.getValueOrThrow(outputDirectoryKey, IOException.class, FileSymlinkException.class, InconsistentFilesystemException.class);
} catch (IOException | FileSymlinkException | InconsistentFilesystemException e) {
throw new RepositoryFunctionException(new IOException("Could not access " + repositoryDirectory + ": " + e.getMessage()), Transience.PERSISTENT);
}
return value;
}
Aggregations