static vs data folder

This commit is contained in:
GitHub
2025-07-25 23:23:24 +08:00
parent f12b8fe299
commit add0a33e3b
3 changed files with 12 additions and 16 deletions

9
.gitignore vendored
View File

@@ -1,11 +1,4 @@
/target
/freedit.db*
/certs
/static/imgs
.rustc_info.json
.rustdoc_fingerprint.json
config.toml
/snapshots
/tantivy
/static/podcasts
.DS_Store
/data

View File

@@ -17,6 +17,7 @@ pub struct Config {
pub(crate) upload_path: String,
pub(crate) tantivy_path: String,
pub(crate) podcast_path: String,
pub snapshots_path: String,
pub(crate) proxy: String,
}
@@ -42,6 +43,7 @@ impl Config {
check_path(&config.upload_path);
check_path(&config.tantivy_path);
check_path(&config.podcast_path);
check_path(&config.snapshots_path);
config
}
@@ -50,14 +52,15 @@ impl Config {
impl Default for Config {
fn default() -> Self {
Config {
db: "freedit.db".into(),
db: "data/freedit.db".into(),
addr: "127.0.0.1:3001".into(),
rebuild_index: None,
avatars_path: "static/imgs/avatars".into(),
inn_icons_path: "static/imgs/inn_icons".into(),
upload_path: "static/imgs/upload".into(),
podcast_path: "static/podcasts".into(),
tantivy_path: "tantivy".into(),
avatars_path: "data/imgs/avatars".into(),
inn_icons_path: "data/imgs/inn_icons".into(),
upload_path: "data/imgs/upload".into(),
podcast_path: "data/podcasts".into(),
tantivy_path: "data/tantivy".into(),
snapshots_path: "data/snapshots".into(),
proxy: "".into(),
}
}

View File

@@ -93,7 +93,7 @@ fn create_snapshot(db: &sled::Db) {
info!(%checksum);
let ts = Timestamp::now().strftime("%Y-%m-%d-%H-%M-%S");
let mut snapshot_path = PathBuf::from("snapshots");
let mut snapshot_path = PathBuf::from(&CONFIG.snapshots_path);
if !snapshot_path.exists() {
fs::create_dir_all(&snapshot_path).unwrap();
}