Search in sources :

Example 6 with FileSymlinkException

use of com.google.devtools.build.lib.skyframe.FileSymlinkException 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;
    }
}
Also used : SkyKey(com.google.devtools.build.skyframe.SkyKey) FileValue(com.google.devtools.build.lib.skyframe.FileValue) LabelSyntaxException(com.google.devtools.build.lib.cmdline.LabelSyntaxException) FileSymlinkException(com.google.devtools.build.lib.skyframe.FileSymlinkException) Label(com.google.devtools.build.lib.cmdline.Label) IOException(java.io.IOException) EvalException(com.google.devtools.build.lib.syntax.EvalException) InconsistentFilesystemException(com.google.devtools.build.lib.skyframe.InconsistentFilesystemException) RootedPath(com.google.devtools.build.lib.vfs.RootedPath)

Example 7 with FileSymlinkException

use of com.google.devtools.build.lib.skyframe.FileSymlinkException 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;
}
Also used : SkyKey(com.google.devtools.build.skyframe.SkyKey) FileValue(com.google.devtools.build.lib.skyframe.FileValue) WorkspaceFileValue(com.google.devtools.build.lib.skyframe.WorkspaceFileValue) FileSymlinkException(com.google.devtools.build.lib.skyframe.FileSymlinkException) IOException(java.io.IOException) InconsistentFilesystemException(com.google.devtools.build.lib.skyframe.InconsistentFilesystemException) Nullable(javax.annotation.Nullable)

Aggregations

FileSymlinkException (com.google.devtools.build.lib.skyframe.FileSymlinkException)7 InconsistentFilesystemException (com.google.devtools.build.lib.skyframe.InconsistentFilesystemException)7 SkyKey (com.google.devtools.build.skyframe.SkyKey)7 IOException (java.io.IOException)7 RootedPath (com.google.devtools.build.lib.vfs.RootedPath)6 FileValue (com.google.devtools.build.lib.skyframe.FileValue)5 Path (com.google.devtools.build.lib.vfs.Path)4 EvalException (com.google.devtools.build.lib.syntax.EvalException)3 Label (com.google.devtools.build.lib.cmdline.Label)2 LabelSyntaxException (com.google.devtools.build.lib.cmdline.LabelSyntaxException)2 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)2 RepositoryFunctionException (com.google.devtools.build.lib.rules.repository.RepositoryFunction.RepositoryFunctionException)1 DirectoryListingValue (com.google.devtools.build.lib.skyframe.DirectoryListingValue)1 PackageLookupValue (com.google.devtools.build.lib.skyframe.PackageLookupValue)1 WorkspaceFileValue (com.google.devtools.build.lib.skyframe.WorkspaceFileValue)1 FileSystem (com.google.devtools.build.lib.vfs.FileSystem)1 ToolPath (com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.ToolPath)1 Properties (java.util.Properties)1 Nullable (javax.annotation.Nullable)1