use of org.gradle.internal.snapshot.DirectorySnapshotBuilder in project gradle by gradle.
the class FileSystemSnapshotBuilder method build.
public FileSystemSnapshot build() {
if (rootFileSnapshot != null) {
return rootFileSnapshot;
}
if (rootDirectoryBuilder == null) {
return FileSystemSnapshot.EMPTY;
}
DirectorySnapshotBuilder builder = MerkleDirectorySnapshotBuilder.sortingRequired();
rootDirectoryBuilder.accept(rootPath, rootName, builder);
return Preconditions.checkNotNull(builder.getResult());
}
use of org.gradle.internal.snapshot.DirectorySnapshotBuilder in project gradle by gradle.
the class FileSystemSnapshotFilter method filterSnapshot.
public static FileSystemSnapshot filterSnapshot(SnapshottingFilter.FileSystemSnapshotPredicate predicate, FileSystemSnapshot unfiltered) {
DirectorySnapshotBuilder builder = MerkleDirectorySnapshotBuilder.noSortingRequired();
AtomicBoolean hasBeenFiltered = new AtomicBoolean(false);
unfiltered.accept(new RelativePathTracker(), new FilteringVisitor(predicate, builder, hasBeenFiltered));
if (builder.getResult() == null) {
return FileSystemSnapshot.EMPTY;
}
return hasBeenFiltered.get() ? builder.getResult() : unfiltered;
}
use of org.gradle.internal.snapshot.DirectorySnapshotBuilder in project gradle by gradle.
the class TarBuildCacheEntryPacker method unpackDirectoryTree.
@Nullable
private TarArchiveEntry unpackDirectoryTree(TarArchiveInputStream input, TarArchiveEntry rootEntry, Map<String, FileSystemLocationSnapshot> snapshots, AtomicLong entries, File treeRoot, String treeName) throws IOException {
RelativePathParser parser = new RelativePathParser(rootEntry.getName());
DirectorySnapshotBuilder builder = MerkleDirectorySnapshotBuilder.noSortingRequired();
builder.enterDirectory(DIRECT, stringInterner.intern(treeRoot.getAbsolutePath()), stringInterner.intern(treeRoot.getName()), INCLUDE_EMPTY_DIRS);
TarArchiveEntry entry;
while ((entry = input.getNextTarEntry()) != null) {
boolean isDir = entry.isDirectory();
boolean outsideOfRoot = parser.nextPath(entry.getName(), isDir, builder::leaveDirectory);
if (outsideOfRoot) {
break;
}
entries.incrementAndGet();
File file = new File(treeRoot, parser.getRelativePath());
if (isDir) {
FileUtils.forceMkdir(file);
chmodUnpackedFile(entry, file);
String internedAbsolutePath = stringInterner.intern(file.getAbsolutePath());
String internedName = stringInterner.intern(parser.getName());
builder.enterDirectory(DIRECT, internedAbsolutePath, internedName, INCLUDE_EMPTY_DIRS);
} else {
RegularFileSnapshot fileSnapshot = unpackFile(input, entry, file, parser.getName());
builder.visitLeafElement(fileSnapshot);
}
}
parser.exitToRoot(builder::leaveDirectory);
builder.leaveDirectory();
snapshots.put(treeName, builder.getResult());
return entry;
}
Aggregations