Skip to content

Commit 3196974

Browse files
committed
Merge pull request #776 from vladak/mkdir_races
create history data directories for renamed files before spawning the th...
2 parents 4f26165 + 7726a17 commit 3196974

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/org/opensolaris/opengrok/history/FileHistoryCache.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ public void store(History history, Repository repository)
360360
}
361361
} catch (IOException ex) {
362362
OpenGrokLogger.getLogger().log(Level.WARNING,
363-
"isRenamedFile() got exception" + ex);
363+
"isRenamedFile() got exception: " + ex);
364364
}
365365

366366
doFileHistory(map_entry, env, repository, null, root, false);
@@ -382,7 +382,20 @@ public void store(History history, Repository repository)
382382
}
383383
} catch (IOException ex) {
384384
OpenGrokLogger.getLogger().log(Level.WARNING,
385-
"isRenamedFile() got exception" + ex);
385+
"isRenamedFile() got exception: " + ex);
386+
}
387+
}
388+
// The directories for the renamed files have to be created before
389+
// the actual files otherwise storeFile() might be racing for
390+
// mkdirs() if there are multiple renamed files from single directory
391+
// handled in parallel.
392+
for (final String file : renamed_map.keySet()) {
393+
File cache = getCachedFile(new File(env.getSourceRootPath() + file));
394+
File dir = cache.getParentFile();
395+
396+
if (!dir.isDirectory() && !dir.mkdirs()) {
397+
OpenGrokLogger.getLogger().log(Level.WARNING,
398+
"Unable to create cache directory '" + dir + "'.");
386399
}
387400
}
388401
final Repository repositoryF = repository;
@@ -398,7 +411,7 @@ public void run() {
398411
} catch (Exception ex) {
399412
// We want to catch any exception since we are in thread.
400413
OpenGrokLogger.getLogger().log(Level.WARNING,
401-
"doFileHistory() got exception" + ex);
414+
"doFileHistory() got exception: " + ex);
402415
} finally {
403416
latch.countDown();
404417
}

0 commit comments

Comments
 (0)