use of com.facebook.thrift.TException in project buck by facebook.
the class EdenProjectFilesystemDelegate method computeSha1.
private Sha1HashCode computeSha1(Path path, boolean retryWithRealPathIfEdenError) throws IOException {
Preconditions.checkArgument(path.isAbsolute());
Optional<Path> entry = mount.getPathRelativeToProjectRoot(path);
if (entry.isPresent() && !isUnderBindMount(entry.get())) {
try {
return mount.getSha1(entry.get());
} catch (TException e) {
throw new IOException(e);
} catch (EdenError e) {
if (retryWithRealPathIfEdenError) {
// It's possible that an EdenError was thrown because entry.get() was a path to a symlink,
// which is not supported by Eden's getSha1() API. Try again if the real path is different
// from the original path.
Path realPath = path.toRealPath();
if (!realPath.equals(path)) {
return computeSha1(realPath, /* retryWithRealPathIfEdenError */
false);
}
}
throw new IOException(e);
}
}
return delegate.computeSha1(path);
}
use of com.facebook.thrift.TException in project buck by facebook.
the class Main method run.
private static int run(String... args) {
Args argsObject = new Args();
CmdLineParser parser = new CmdLineParser(argsObject);
try {
parser.parseArgument(args);
} catch (CmdLineException e) {
e.printStackTrace();
return 1;
}
try {
return argsObject.run();
} catch (EdenError | IOException | TException e) {
e.printStackTrace();
return 1;
}
}
use of com.facebook.thrift.TException in project buck by facebook.
the class ProjectFilesystemDelegateFactory method newInstance.
/**
* Must always create a new delegate for the specified {@code root}.
*/
public static ProjectFilesystemDelegate newInstance(Path root, String hgCmd, AutoSparseConfig autoSparseConfig) {
Optional<EdenClient> client = tryToCreateEdenClient();
if (client.isPresent()) {
try {
EdenMount mount = client.get().getMountFor(root);
if (mount != null) {
return new EdenProjectFilesystemDelegate(mount);
}
} catch (TException | EdenError e) {
// If Eden is running but root is not a mount point, Eden getMountFor() should just return
// null rather than throw an error.
LOG.error(e, "Failed to find Eden client for %s.", root);
}
}
if (autoSparseConfig.enabled()) {
// We can't access BuckConfig because that class requires a
// ProjectFileSystem, which we are in the process of building
// Access the required info from the Config instead
HgCmdLineInterface hgCmdLine = new HgCmdLineInterface(new PrintStreamProcessExecutorFactory(), root, hgCmd, ImmutableMap.of());
AutoSparseState autoSparseState = AbstractAutoSparseFactory.getAutoSparseState(root, hgCmdLine, autoSparseConfig);
if (autoSparseState != null) {
LOG.debug("Autosparse enabled, using AutoSparseProjectFilesystemDelegate");
return new AutoSparseProjectFilesystemDelegate(autoSparseState, root);
}
}
// No Eden or Mercurial info available, use the default
return new DefaultProjectFilesystemDelegate(root);
}
Aggregations