mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-15 09:11:28 +10:00
chore: Ran cargo clippy & cargo fmt
This commit is contained in:
@ -6,9 +6,15 @@ use std::{
|
||||
|
||||
use serde_json::Value;
|
||||
|
||||
use crate::{database::{db::borrow_db_mut_checked, settings::Settings}, download_manager::{download_manager::DownloadManagerSignal, internal_error::InternalError}, DB};
|
||||
use crate::{
|
||||
database::{db::borrow_db_mut_checked, settings::Settings},
|
||||
download_manager::internal_error::InternalError,
|
||||
};
|
||||
|
||||
use super::{db::{borrow_db_checked, save_db, DATA_ROOT_DIR}, debug::SystemData};
|
||||
use super::{
|
||||
db::{borrow_db_checked, save_db, DATA_ROOT_DIR},
|
||||
debug::SystemData,
|
||||
};
|
||||
|
||||
// Will, in future, return disk/remaining size
|
||||
// Just returns the directories that have been set up
|
||||
@ -36,7 +42,8 @@ pub fn add_download_dir(new_dir: PathBuf) -> Result<(), InternalError<()>> {
|
||||
return Err(Error::new(
|
||||
ErrorKind::DirectoryNotEmpty,
|
||||
"Selected directory cannot contain any existing files",
|
||||
).into());
|
||||
)
|
||||
.into());
|
||||
}
|
||||
} else {
|
||||
create_dir_all(new_dir_path)?;
|
||||
@ -48,7 +55,8 @@ pub fn add_download_dir(new_dir: PathBuf) -> Result<(), InternalError<()>> {
|
||||
return Err(Error::new(
|
||||
ErrorKind::AlreadyExists,
|
||||
"Selected directory already exists in database",
|
||||
).into());
|
||||
)
|
||||
.into());
|
||||
}
|
||||
lock.applications.install_dirs.push(new_dir);
|
||||
drop(lock);
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fs::{self, create_dir_all},
|
||||
path::{Path, PathBuf},
|
||||
path::PathBuf,
|
||||
sync::{LazyLock, Mutex, RwLockReadGuard, RwLockWriteGuard},
|
||||
};
|
||||
|
||||
@ -187,28 +187,30 @@ fn handle_invalid_database(
|
||||
let new_path = {
|
||||
let time = Utc::now().timestamp();
|
||||
let mut base = db_path.clone();
|
||||
base.set_file_name(format!("drop.db.backup-{}", time.to_string()));
|
||||
base.set_file_name(format!("drop.db.backup-{}", time));
|
||||
base
|
||||
};
|
||||
info!("old database stored at: {}", new_path.to_string_lossy().to_string());
|
||||
info!(
|
||||
"old database stored at: {}",
|
||||
new_path.to_string_lossy().to_string()
|
||||
);
|
||||
fs::rename(&db_path, &new_path).unwrap();
|
||||
|
||||
let db = Database::new(
|
||||
games_base_dir.into_os_string().into_string().unwrap(),
|
||||
Some(new_path.into()),
|
||||
Some(new_path),
|
||||
);
|
||||
|
||||
PathDatabase::create_at_path(db_path, db).expect("Database could not be created")
|
||||
}
|
||||
|
||||
|
||||
pub fn borrow_db_checked<'a>() -> RwLockReadGuard<'a, Database> {
|
||||
match DB.borrow_data() {
|
||||
Ok(data) => data,
|
||||
Err(e) => {
|
||||
error!("database borrow failed with error {}", e);
|
||||
panic!("database borrow failed with error {}", e);
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -224,10 +226,10 @@ pub fn borrow_db_mut_checked<'a>() -> RwLockWriteGuard<'a, Database> {
|
||||
|
||||
pub fn save_db() {
|
||||
match DB.save() {
|
||||
Ok(_) => {},
|
||||
Ok(_) => {}
|
||||
Err(e) => {
|
||||
error!("database failed to save with error {}", e);
|
||||
panic!("database failed to save with error {}", e)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
use crate::{DATA_ROOT_DIR, DB};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
||||
Reference in New Issue
Block a user