File tree Expand file tree Collapse file tree 3 files changed +301
-5
lines changed
Expand file tree Collapse file tree 3 files changed +301
-5
lines changed Original file line number Diff line number Diff line change 3838# Environment variables - IMPORTANT: Never commit this!
3939.env
4040
41- # State files
42- /data /
43- state.json
41+ # State files (old - see bottom for better pattern)
4442
4543# OS files
4644.DS_Store
@@ -56,3 +54,7 @@ desktop.ini
5654# Docker
5755.dockerignore
5856docker-compose.override.yml
57+
58+ # Data directory - ignore everything except state.json
59+ data /*
60+ ! data /state.json
Original file line number Diff line number Diff line change 33
44public static class StateStore
55{
6- static readonly string PathFile = "/data/state.json" ;
6+ static readonly string DataDir = Environment . GetEnvironmentVariable ( "DATA_DIR" ) ?? "./data" ;
7+ static readonly string PathFile = Path . Combine ( DataDir , "state.json" ) ;
78 static readonly JsonSerializerOptions J = new ( ) { WriteIndented = true } ;
89
910 public static StateOfWorld Load ( )
@@ -14,7 +15,7 @@ public static StateOfWorld Load()
1415
1516 public static void Save ( StateOfWorld s )
1617 {
17- Directory . CreateDirectory ( "/data" ) ;
18+ Directory . CreateDirectory ( DataDir ) ;
1819 File . WriteAllText ( PathFile , JsonSerializer . Serialize ( s , J ) ) ;
1920 }
2021
You can’t perform that action at this time.
0 commit comments