use of build.buildfarm.common.io.Dirent in project bazel-buildfarm by bazelbuild.
the class CFCExecFileSystem method start.
@SuppressWarnings("ConstantConditions")
@Override
public void start(Consumer<List<Digest>> onDigests, boolean skipLoad) throws IOException, InterruptedException {
List<Dirent> dirents = null;
try {
dirents = readdir(root, /* followSymlinks= */
false, Files.getFileStore(root));
} catch (IOException e) {
logger.log(Level.SEVERE, "error reading directory " + root.toString(), e);
}
ImmutableList.Builder<ListenableFuture<Void>> removeDirectoryFutures = ImmutableList.builder();
// only valid path under root is cache
for (Dirent dirent : dirents) {
String name = dirent.getName();
Path child = root.resolve(name);
if (!child.equals(fileCache.getRoot())) {
removeDirectoryFutures.add(Directories.remove(root.resolve(name), removeDirectoryService));
}
}
ImmutableList.Builder<Digest> blobDigests = ImmutableList.builder();
fileCache.start(digest -> {
synchronized (blobDigests) {
blobDigests.add(digest);
}
}, removeDirectoryService, skipLoad);
onDigests.accept(blobDigests.build());
getInterruptiblyOrIOException(allAsList(removeDirectoryFutures.build()));
}
use of build.buildfarm.common.io.Dirent in project bazel-buildfarm by bazelbuild.
the class UploadManifest method computeDirectory.
private Directory computeDirectory(Path path, Tree.Builder tree) throws IllegalStateException, IOException {
Directory.Builder b = Directory.newBuilder();
List<Dirent> sortedDirent = readdir(path, /* followSymlinks= */
false, fileStore);
sortedDirent.sort(Comparator.comparing(Dirent::getName));
for (Dirent dirent : sortedDirent) {
String name = dirent.getName();
Path child = path.resolve(name);
if (dirent.getType() == Dirent.Type.DIRECTORY) {
Directory dir = computeDirectory(child, tree);
b.addDirectoriesBuilder().setName(name).setDigest(digestUtil.compute(dir));
tree.addChildren(dir);
} else if (dirent.getType() == Dirent.Type.FILE || (dirent.getType() == Dirent.Type.SYMLINK && allowSymlinks)) {
Digest digest = digestUtil.compute(child);
b.addFilesBuilder().setName(name).setDigest(digest).setIsExecutable(Files.isExecutable(child));
digestToFile.put(digest, child);
} else {
illegalOutput(child);
}
}
return b.build();
}
Aggregations