use of com.google.copybara.util.AbsoluteSymlinksNotAllowed in project copybara by google.
the class FolderOrigin method newReader.
@Override
public Reader<FolderRevision> newReader(Glob originFiles, Authoring authoring) throws ValidationException {
return new Reader<FolderRevision>() {
@Override
public void checkout(FolderRevision ref, Path workdir) throws RepoException, ValidationException {
try {
FileUtil.copyFilesRecursively(ref.path, workdir, copySymlinkStrategy, originFiles);
FileUtil.addPermissionsAllRecursively(workdir, FILE_PERMISSIONS);
} catch (AbsoluteSymlinksNotAllowed e) {
throw new ValidationException("Cannot copy files into the workdir: Some" + " symlinks refer to locations outside of the folder and" + " 'materialize_outside_symlinks' config option was not used:\n" + " %s -> %s\n", e.getSymlink(), e.getDestinationFile());
} catch (IOException e) {
throw new RepoException(String.format("Cannot copy files into the workdir:\n" + " origin folder: %s\n" + " workdir: %s", ref.path, workdir), e);
}
}
@Override
public ChangesResponse<FolderRevision> changes(@Nullable FolderRevision fromRef, FolderRevision toRef) throws RepoException {
// Ignore fromRef since a folder doesn't have history of changes
return ChangesResponse.forChanges(ImmutableList.of(change(toRef)));
}
@Override
public boolean supportsHistory() {
return false;
}
@Override
public Change<FolderRevision> change(FolderRevision ref) throws RepoException {
return new Change<>(ref, author, message, ref.readTimestamp(), ImmutableMap.of());
}
@Override
public void visitChanges(FolderRevision start, ChangesVisitor visitor) throws RepoException {
visitor.visit(change(start));
}
};
}
Aggregations