Skip to content

Commit edcf642

Browse files
authored
Merge pull request #251 from julia-vscode/fix-race-condition
Fix a race condition
2 parents 0792cc8 + 2eff0d8 commit edcf642

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

src/SymbolServer.jl

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,34 @@ function getstore(ssi::SymbolServerInstance, environment_path::AbstractString, p
3232

3333
# see if we can download any package cache's before
3434
if download
35-
download_dir = joinpath(ssi.store_path, "_downloads")
36-
ispath(download_dir) && rm(download_dir, force = true, recursive = true)
37-
mkpath(download_dir)
38-
manifest_filename = isfile(joinpath(environment_path, "JuliaManifest.toml")) ? joinpath(environment_path, "JuliaManifest.toml") : joinpath(environment_path, "Manifest.toml")
39-
if isfile(manifest_filename)
40-
let manifest = read_manifest(manifest_filename)
41-
if manifest !== nothing
42-
@debug "Downloading cache files for manifest at $(manifest_filename)."
43-
to_download = collect(validate_disc_store(ssi.store_path, manifest))
44-
batches = Iterators.partition(to_download, max(1, floor(Int, length(to_download)÷50)))
45-
for (i, batch) in enumerate(batches)
46-
percentage = round(Int, 100*(i - 1)/length(batches))
47-
progress_callback !== nothing && progress_callback("Downloading caches...", percentage)
48-
@sync for pkg in batch
49-
@async begin
50-
yield()
51-
uuid = packageuuid(pkg)
52-
get_file_from_cloud(manifest, uuid, environment_path, ssi.depot_path, ssi.store_path, download_dir, ssi.symbolcache_upstream)
53-
yield()
35+
download_dir_parent = joinpath(ssi.store_path, "_downloads")
36+
mkpath(download_dir_parent)
37+
38+
mktempdir(download_dir_parent) do download_dir
39+
manifest_filename = isfile(joinpath(environment_path, "JuliaManifest.toml")) ? joinpath(environment_path, "JuliaManifest.toml") : joinpath(environment_path, "Manifest.toml")
40+
if isfile(manifest_filename)
41+
let manifest = read_manifest(manifest_filename)
42+
if manifest !== nothing
43+
@debug "Downloading cache files for manifest at $(manifest_filename)."
44+
to_download = collect(validate_disc_store(ssi.store_path, manifest))
45+
batches = Iterators.partition(to_download, max(1, floor(Int, length(to_download)÷50)))
46+
for (i, batch) in enumerate(batches)
47+
percentage = round(Int, 100*(i - 1)/length(batches))
48+
progress_callback !== nothing && progress_callback("Downloading caches...", percentage)
49+
@sync for pkg in batch
50+
@async begin
51+
yield()
52+
uuid = packageuuid(pkg)
53+
get_file_from_cloud(manifest, uuid, environment_path, ssi.depot_path, ssi.store_path, download_dir, ssi.symbolcache_upstream)
54+
yield()
55+
end
5456
end
5557
end
58+
progress_callback !== nothing && progress_callback("All cache files downloaded.", 100)
5659
end
57-
progress_callback !== nothing && progress_callback("All cache files downloaded.", 100)
5860
end
5961
end
6062
end
61-
ispath(download_dir) && rm(download_dir, force = true, recursive = true)
6263
end
6364

6465
jl_cmd = joinpath(Sys.BINDIR, Base.julia_exename())

0 commit comments

Comments
 (0)