@@ -191,7 +191,8 @@ public boolean supportsRepository(Repository repository) {
191
191
* @param file the file to find the cache for
192
192
* @return file that might contain cached history for <code>file</code>
193
193
*/
194
- private static File getCachedFile (File file ) throws HistoryException {
194
+ private static File getCachedFile (File file ) throws HistoryException ,
195
+ ForbiddenSymlinkException {
195
196
RuntimeEnvironment env = RuntimeEnvironment .getInstance ();
196
197
197
198
StringBuilder sb = new StringBuilder ();
@@ -210,7 +211,7 @@ private static File getCachedFile(File file) throws HistoryException {
210
211
sb .append (DIRECTORY_FILE_PREFIX );
211
212
}
212
213
sb .append (".gz" );
213
- } catch (IOException | ForbiddenSymlinkException e ) {
214
+ } catch (IOException e ) {
214
215
throw new HistoryException ("Failed to get path relative to " +
215
216
"source root for " + file , e );
216
217
}
@@ -343,7 +344,13 @@ private History mergeOldAndNewHistory(File cacheFile, History histNew, Repositor
343
344
private void storeFile (History histNew , File file , Repository repo ,
344
345
boolean mergeHistory ) throws HistoryException {
345
346
346
- File cacheFile = getCachedFile (file );
347
+ File cacheFile ;
348
+ try {
349
+ cacheFile = getCachedFile (file );
350
+ } catch (ForbiddenSymlinkException e ) {
351
+ LOGGER .log (Level .FINER , e .getMessage ());
352
+ return ;
353
+ }
347
354
History history = histNew ;
348
355
349
356
File dir = cacheFile .getParentFile ();
@@ -504,7 +511,13 @@ public void store(History history, Repository repository)
504
511
// mkdirs() if there are multiple renamed files from single directory
505
512
// handled in parallel.
506
513
for (final String file : renamed_map .keySet ()) {
507
- File cache = getCachedFile (new File (env .getSourceRootPath () + file ));
514
+ File cache ;
515
+ try {
516
+ cache = getCachedFile (new File (env .getSourceRootPath () + file ));
517
+ } catch (ForbiddenSymlinkException ex ) {
518
+ LOGGER .log (Level .FINER , ex .getMessage ());
519
+ continue ;
520
+ }
508
521
File dir = cache .getParentFile ();
509
522
510
523
if (!dir .isDirectory () && !dir .mkdirs ()) {
@@ -546,7 +559,7 @@ public void run() {
546
559
547
560
@ Override
548
561
public History get (File file , Repository repository , boolean withFiles )
549
- throws HistoryException {
562
+ throws HistoryException , ForbiddenSymlinkException {
550
563
File cache = getCachedFile (file );
551
564
if (isUpToDate (file , cache )) {
552
565
try {
@@ -640,7 +653,12 @@ public boolean hasCacheForDirectory(File directory, Repository repository)
640
653
641
654
@ Override
642
655
public boolean hasCacheForFile (File file ) throws HistoryException {
643
- return getCachedFile (file ).exists ();
656
+ try {
657
+ return getCachedFile (file ).exists ();
658
+ } catch (ForbiddenSymlinkException ex ) {
659
+ LOGGER .log (Level .FINER , ex .getMessage ());
660
+ return false ;
661
+ }
644
662
}
645
663
646
664
public String getRepositoryHistDataDirname (Repository repository ) {
@@ -767,6 +785,9 @@ public void clearFile(String path) {
767
785
File historyFile ;
768
786
try {
769
787
historyFile = getCachedFile (new File (env .getSourceRootPath () + path ));
788
+ } catch (ForbiddenSymlinkException ex ) {
789
+ LOGGER .log (Level .FINER , ex .getMessage ());
790
+ return ;
770
791
} catch (HistoryException ex ) {
771
792
LOGGER .log (Level .WARNING , "cannot get history file for file " + path , ex );
772
793
return ;
0 commit comments