File tree Expand file tree Collapse file tree 2 files changed +27
-3
lines changed
Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -294,11 +294,35 @@ See $workspacesDocUrl for more information.
294294 }
295295 }
296296
297+ /// We check each directory that it doesn't symlink-resolve to the
298+ /// symlink-resolution of any parent directory of itself. This avoids
299+ /// cycles.
300+ ///
301+ /// Cache the symlink resolutions here.
302+ final symlinkResolvedDirs = < String , String > {};
303+
297304 final result = Ignore .listFiles (
298305 beneath: beneath,
299306 listDir: (dir) {
300- final resolvedDir = resolve (dir);
307+ final resolvedDir = p. normalize ( resolve (dir) );
301308 verifyLink (resolvedDir);
309+
310+ {
311+ final symlinkResolvedDir = symlinkResolvedDirs[resolvedDir] ?? =
312+ Directory (resolvedDir).resolveSymbolicLinksSync ();
313+
314+ for (final parent in parentDirs (p.dirname (resolvedDir))) {
315+ final symlinkResolvedParent = symlinkResolvedDirs[parent] ?? =
316+ Directory (parent).resolveSymbolicLinksSync ();
317+ if (p.equals (symlinkResolvedDir, symlinkResolvedParent)) {
318+ dataError ('''
319+ Pub does not support symlink cycles.
320+
321+ $resolvedDir => ${p .canonicalize (parent )}
322+ ''' );
323+ }
324+ }
325+ }
302326 var contents = Directory (resolvedDir).listSync (followLinks: false );
303327
304328 if (! recursive) {
Original file line number Diff line number Diff line change @@ -150,7 +150,7 @@ void main() {
150150 (e) => e.message,
151151 'message' ,
152152 contains (
153- 'Could not resolve symbolic link ' ,
153+ 'Pub does not support symlink cycles. ' ,
154154 ),
155155 ),
156156 ),
@@ -221,7 +221,7 @@ void main() {
221221 isA <DataException >().having (
222222 (e) => e.message,
223223 'message' ,
224- contains ('Could not resolve symbolic link ' ),
224+ contains ('Pub does not support symlink cycles. ' ),
225225 ),
226226 ),
227227 );
You can’t perform that action at this time.
0 commit comments