Skip to content

Commit 102f5cf

Browse files
committed
check dirs are safe for removal
1 parent 0138e36 commit 102f5cf

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

src/AGNI.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,10 @@ module AGNI
584584
# Frame dir
585585
if plt_ani
586586
@debug "Will animate"
587+
if !paths.is_safe_dir(atmos.FRAMES_DIR)
588+
@error "Frame directory is unsafe! Got: $(atmos.FRAMES_DIR)"
589+
return false
590+
end
587591
rm(atmos.FRAMES_DIR,force=true,recursive=true)
588592
mkdir(atmos.FRAMES_DIR)
589593
end
@@ -862,6 +866,9 @@ module AGNI
862866
output_dir = abspath(cfg["files"]["output_dir"])
863867
clean_output = Bool(cfg["execution"]["clean_output"])
864868
if clean_output || !isdir(output_dir)
869+
if !paths.is_safe_dir(output_dir)
870+
error("Output directory is unsafe! Got: $output_dir")
871+
end
865872
rm(output_dir,force=true,recursive=true)
866873
mkdir(output_dir)
867874
end

src/interface/load.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
"""
66
module load
77

8-
import ..atmosphere
9-
108
using NCDatasets
119
using LoggingExtras
1210
using Printf
1311

12+
import ..atmosphere
13+
1414
"""
1515
**Load atmosphere data from a NetCDF file.**
1616
@@ -101,7 +101,7 @@ module load
101101
end
102102

103103
# recalculate remaining layer properties
104-
calc_layer_props!(atmos)
104+
atmosphere.calc_layer_props!(atmos)
105105

106106
close(ds)
107107

src/state/atmosphere.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ module atmosphere
619619
atmos.OUT_DIR = abspath(OUT_DIR)
620620
if !paths.is_safe_dir(atmos.OUT_DIR)
621621
@error "Output directory is not safe to write to!"
622-
@error " OUT_DIR=$(atmos.OUT_DIR)"
622+
@error " Got: $(atmos.OUT_DIR)"
623623
return false
624624
end
625625
if !isdir(atmos.OUT_DIR) && !isfile(atmos.OUT_DIR)
@@ -1233,6 +1233,10 @@ module atmosphere
12331233
end
12341234

12351235
# re-make FC working directory
1236+
if !paths.is_safe_dir(atmos.fastchem_work)
1237+
@error "Cannot use FastChem working directory! Got: $(atmos.fastchem_work)"
1238+
return false
1239+
end
12361240
rm(atmos.fastchem_work,force=true,recursive=true)
12371241
mkdir(atmos.fastchem_work)
12381242
else
@@ -1276,6 +1280,10 @@ module atmosphere
12761280
end
12771281

12781282
# re-make working directory
1283+
if !paths.is_safe_dir(atmos.rfm_work)
1284+
@error "Cannot use RFM working directory! Got: $(atmos.rfm_work)"
1285+
return false
1286+
end
12791287
rm(atmos.rfm_work,force=true,recursive=true)
12801288
mkdir(atmos.rfm_work)
12811289
end

0 commit comments

Comments
 (0)