Skip to content

Commit 7184608

Browse files
authored
call GC.gc() before every rm in Windows (#91)
1 parent fbbc4e5 commit 7184608

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/generate.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ function makedemos(source::String, templates::Union{Dict, Nothing} = nothing;
164164
end
165165
if clean_builddir
166166
@info "Remove DemoCards build dir: $absolute_root"
167+
# Ref: https://discourse.julialang.org/t/find-what-has-locked-held-a-file/23278/2
168+
Base.Sys.iswindows() && GC.gc()
167169
rm(absolute_root; force=true, recursive=true)
168170
else
169171
error("Stopped demos build.")
@@ -200,12 +202,18 @@ function makedemos(source::String, templates::Union{Dict, Nothing} = nothing;
200202
end
201203

202204
@info "Clean up DemoCards build dir: \"$source\""
205+
# Ref: https://discourse.julialang.org/t/find-what-has-locked-held-a-file/23278/2
206+
Base.Sys.iswindows() && GC.gc()
203207
rm(absolute_root; force=true, recursive=true)
204208

205209
if !isnothing(theme_assets)
206210
assets_path = abspath(root, src, theme_assets)
211+
# Ref: https://discourse.julialang.org/t/find-what-has-locked-held-a-file/23278/2
212+
Base.Sys.iswindows() && GC.gc()
207213
rm(assets_path, force=true)
208214
if(isempty(readdir(dirname(assets_path))))
215+
# Ref: https://discourse.julialang.org/t/find-what-has-locked-held-a-file/23278/2
216+
Base.Sys.iswindows() && GC.gc()
209217
rm(dirname(assets_path))
210218
end
211219
end
@@ -216,6 +224,8 @@ function makedemos(source::String, templates::Union{Dict, Nothing} = nothing;
216224
catch err
217225
# clean up build dir if anything wrong happens here so that we _hopefully_ never trigger the
218226
# user prompt logic before the build process.
227+
# Ref: https://discourse.julialang.org/t/find-what-has-locked-held-a-file/23278/2
228+
Base.Sys.iswindows() && GC.gc()
219229
rm(absolute_root; force=true, recursive=true)
220230
@error "Errors when building demo dir" pwd=pwd() source root src
221231
rethrow(err)

0 commit comments

Comments
 (0)