@@ -44,6 +44,19 @@ private FileAccessTree(FilesEntitlement filesEntitlement, PathLookup pathLookup)
4444 }
4545 readPaths .add (normalized );
4646 };
47+ BiConsumer <Path , Mode > maybeAddLinkPath = (path , mode ) -> {
48+ // also try to follow symlinks. Lucene does this and writes to the target path.
49+ if (Files .exists (path )) {
50+ try {
51+ Path realPath = path .toRealPath ();
52+ if (realPath .equals (path ) == false ) {
53+ addPath .accept (realPath , mode );
54+ }
55+ } catch (IOException e ) {
56+ throw new UncheckedIOException (e );
57+ }
58+ }
59+ };
4760 for (FilesEntitlement .FileData fileData : filesEntitlement .filesData ()) {
4861 var mode = fileData .mode ();
4962 var paths = fileData .resolvePaths (pathLookup );
@@ -53,25 +66,13 @@ private FileAccessTree(FilesEntitlement filesEntitlement, PathLookup pathLookup)
5366 return ;
5467 }
5568 addPath .accept (path , mode );
56- // also try to follow symlinks. Lucene does this and writes to the target path.
57- if (Files .exists (path )) {
58- try {
59- Path realPath = path .toRealPath ();
60- if (realPath .equals (path ) == false ) {
61- addPath .accept (realPath , mode );
62- }
63- } catch (IOException e ) {
64- throw new UncheckedIOException (e );
65- }
66- }
69+ maybeAddLinkPath .accept (path , mode );
6770 });
6871 }
6972
7073 // everything has access to the temp dir
71- String tempDir = normalizePath (pathLookup .tempDir ());
72- logger .info ("Adding temp dir [{}] to file access tree" , tempDir );
73- readPaths .add (tempDir );
74- writePaths .add (tempDir );
74+ addPath .accept (pathLookup .tempDir (), Mode .READ_WRITE );
75+ maybeAddLinkPath .accept (pathLookup .tempDir (), Mode .READ_WRITE );
7576
7677 readPaths .sort (String ::compareTo );
7778 writePaths .sort (String ::compareTo );
0 commit comments