add a --clean param
parent
2b74aea57d
commit
2173ca5b51
20
src/main.rs
20
src/main.rs
|
@ -12,7 +12,7 @@ use std::path::PathBuf;
|
||||||
use actix_web::{middleware, App, HttpServer};
|
use actix_web::{middleware, App, HttpServer};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use clap::{App as ClapApp, Arg};
|
use clap::{App as ClapApp, Arg};
|
||||||
use log::{info, warn};
|
use log::{debug, info, warn};
|
||||||
use std::sync::{Arc, RwLock};
|
use std::sync::{Arc, RwLock};
|
||||||
|
|
||||||
use crate::{common::PKG_VERSION, database::UpEndDatabase};
|
use crate::{common::PKG_VERSION, database::UpEndDatabase};
|
||||||
|
@ -66,6 +66,11 @@ fn main() -> Result<()> {
|
||||||
.long("no-initial-update")
|
.long("no-initial-update")
|
||||||
.help("Don't run a database update on start."),
|
.help("Don't run a database update on start."),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("CLEAN")
|
||||||
|
.long("clean")
|
||||||
|
.help("Clean up temporary files (e.g. previews) on start."),
|
||||||
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("REINITIALIZE")
|
Arg::with_name("REINITIALIZE")
|
||||||
.long("reinitialize")
|
.long("reinitialize")
|
||||||
|
@ -104,12 +109,23 @@ fn main() -> Result<()> {
|
||||||
let ui_enabled = ui_path.exists() && !matches.is_present("NO_UI");
|
let ui_enabled = ui_path.exists() && !matches.is_present("NO_UI");
|
||||||
let browser_enabled = desktop_enabled && !matches.is_present("NO_BROWSER");
|
let browser_enabled = desktop_enabled && !matches.is_present("NO_BROWSER");
|
||||||
|
|
||||||
|
let preview_path = upend.db_path.join("previews");
|
||||||
#[cfg(feature = "previews")]
|
#[cfg(feature = "previews")]
|
||||||
let preview_store = Some(Arc::new(crate::previews::PreviewStore::new(
|
let preview_store = Some(Arc::new(crate::previews::PreviewStore::new(
|
||||||
upend.db_path.join("previews"),
|
preview_path.clone(),
|
||||||
upend.clone(),
|
upend.clone(),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
if matches.is_present("CLEAN") {
|
||||||
|
info!("Cleaning temporary directories...");
|
||||||
|
if preview_path.exists() {
|
||||||
|
std::fs::remove_dir_all(&preview_path).unwrap();
|
||||||
|
debug!("Removed {preview_path:?}");
|
||||||
|
} else {
|
||||||
|
debug!("No preview path exists, continuing...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "previews"))]
|
#[cfg(not(feature = "previews"))]
|
||||||
let preview_store = None;
|
let preview_store = None;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue