Skip to content

Commit

Permalink
Work around symlink loop bug
Browse files Browse the repository at this point in the history
Julia has a bug with `walkdir()` and symlink loops:
JuliaLang/julia#35006
  • Loading branch information
staticfloat committed Mar 5, 2020
1 parent a2512fc commit 38e0c38
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/wizard/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,18 @@ function with_logfile(f::Function, logfile::String)
end

function prepare_for_deletion(prefix::String)
for (root, dirs, files) in walkdir(prefix)
for d in dirs
# Ensure that each directory is writable by by the owning user (should be us)
path = joinpath(root, d)
try
chmod(path, stat(path).mode | Base.Filesystem.S_IWUSR)
catch
# Temporarily work around walkdir bug with endless symlinks: https://github.com/JuliaLang/julia/pull/35006
try
for (root, dirs, files) in walkdir(prefix; follow_symlinks=false)
for d in dirs
# Ensure that each directory is writable by by the owning user (should be us)
path = joinpath(root, d)
try
chmod(path, stat(path).mode | Base.Filesystem.S_IWUSR)
catch
end
end
end
catch
end
end

0 comments on commit 38e0c38

Please sign in to comment.