Skip to content

Commit 6f9006e

Browse files
authored
Merge pull request #275 from JuliaRobotics/feat/1Q20/untardel
delete temp folder from tar
2 parents 6ebb75e + 4195bc3 commit 6f9006e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/FileDFG/services/FileDFG.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,13 @@ function loadDFG(dst::String, iifModule, dfgLoadInto::G; loaddir=joinpath("/","t
8787
lastdirname *= ".tar.gz"
8888
end
8989
end
90+
# TODO -- what if it is not a tar.gz but classic folder instead?
9091
# do actual unzipping
92+
filename = lastdirname[1:(end-length(".tar.gz"))] |> string
9193
if unzip
9294
@show sfolder = split(dstname, '.')
9395
Base.mkpath(loaddir)
94-
folder = joinpath(loaddir, lastdirname[1:(end-length(".tar.gz"))]) #splitpath(string(sfolder[end-2]))[end]
96+
folder = joinpath(loaddir, filename) #splitpath(string(sfolder[end-2]))[end]
9597
@info "loadDFG detected a gzip $dstname -- unpacking via $loaddir now..."
9698
Base.rm(folder, recursive=true, force=true)
9799
# unzip the tar file
@@ -140,5 +142,12 @@ function loadDFG(dst::String, iifModule, dfgLoadInto::G; loaddir=joinpath("/","t
140142
# TODO: Remove in future
141143
map(f->solverData(f).fncargvID = f._variableOrderSymbols, getFactors(dfgLoadInto))
142144

145+
# remove the temporary unzipped file
146+
if unzip
147+
@info "DFG.loadDFG is deleting a temp folder created during unzip, $folder"
148+
# need this because the number of files created in /tmp/caesar/random is becoming redonkulous.
149+
Base.rm(folder, recursive=true)
150+
end
151+
143152
return dfgLoadInto
144153
end

0 commit comments

Comments
 (0)