use of org.opengrok.indexer.util.ForbiddenSymlinkException in project OpenGrok by OpenGrok.
the class FileHistoryCache method createDirectoriesForFiles.
private void createDirectoriesForFiles(Set<String> files, Repository repository, String label) throws HistoryException {
// The directories for the files have to be created before
// the actual files otherwise storeFile() might be racing for
// mkdirs() if there are multiple files from single directory
// handled in parallel.
Statistics elapsed = new Statistics();
LOGGER.log(Level.FINE, "Starting directory creation for {0} ({1}): {2} directories", new Object[] { repository, label, files.size() });
for (final String file : files) {
File cache;
try {
cache = getCachedFile(new File(env.getSourceRootPath() + file));
} catch (ForbiddenSymlinkException ex) {
LOGGER.log(Level.FINER, ex.getMessage());
continue;
}
File dir = cache.getParentFile();
if (!dir.isDirectory() && !dir.mkdirs()) {
LOGGER.log(Level.WARNING, "Unable to create cache directory ''{0}''.", dir);
}
}
elapsed.report(LOGGER, String.format("Done creating directories for %s (%s)", repository, label));
}
use of org.opengrok.indexer.util.ForbiddenSymlinkException in project OpenGrok by OpenGrok.
the class FileHistoryCache method storeFile.
/**
* Store history object (encoded as XML and compressed with gzip) in a file.
*
* @param histNew history object to store
* @param file file to store the history object into
* @param repo repository for the file
* @param mergeHistory whether to merge the history with existing or
* store the histNew as is
*/
private void storeFile(History histNew, File file, Repository repo, boolean mergeHistory) throws HistoryException {
File cacheFile;
try {
cacheFile = getCachedFile(file);
} catch (ForbiddenSymlinkException e) {
LOGGER.log(Level.FINER, e.getMessage());
return;
}
History history = histNew;
File dir = cacheFile.getParentFile();
// calling isDirectory twice to prevent a race condition
if (!dir.isDirectory() && !dir.mkdirs() && !dir.isDirectory()) {
throw new HistoryException("Unable to create cache directory '" + dir + "'.");
}
if (mergeHistory && cacheFile.exists()) {
history = mergeOldAndNewHistory(cacheFile, histNew, repo);
}
// In such case store at least new history as the best effort.
if (history == null) {
LOGGER.log(Level.WARNING, "history cache for file ''{0}'' truncated to new history", file);
history = histNew;
}
writeHistoryToFile(dir, history, cacheFile);
}
Aggregations