Implemented cleanup of binary files

This commit is contained in:
Giorgio Calderone 2020-03-29 14:21:11 +02:00
parent 234651ca25
commit e3cdf7a5e0

View File

@ -444,6 +444,7 @@ end
# ╰───────────────────────────────────────────────────────────────────╯ # ╰───────────────────────────────────────────────────────────────────╯
# --------------------------------------------------------------------- # ---------------------------------------------------------------------
function reset(gp::DrySession) function reset(gp::DrySession)
delete_binaries(gp)
gp.datas = Dict{String, DataSet}() gp.datas = Dict{String, DataSet}()
gp.plots = [SinglePlot()] gp.plots = [SinglePlot()]
gp.curmid = 1 gp.curmid = 1
@ -486,7 +487,7 @@ function add_dataset(gp::DrySession, name::String, args...)
return gpsource return gpsource
catch err catch err
if isa(err, MethodError) if isa(err, MethodError)
@warn "No method to handle binary data, resort to inline datablock..." @warn "No method to write data as a binary file, resort to inline datablock..."
else else
rethrow() rethrow()
end end
@ -517,8 +518,19 @@ function add_plot(gp::DrySession, plotspec)
end end
# ---------------------------------------------------------------------
function delete_binaries(gp::DrySession)
for (name, d) in gp.datas
if d.file != "" # delete binary files
rm(d.file, force=true)
end
end
end
# --------------------------------------------------------------------- # ---------------------------------------------------------------------
function quit(gp::DrySession) function quit(gp::DrySession)
delete_binaries(gp)
delete!(sessions, gp.sid) delete!(sessions, gp.sid)
return 0 return 0
end end