mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-10 04:22:13 +10:00
* feat: different local path in dev #73 * feat: better error output for downloads * feat: collections in library view * feat: improve download manager reliability * feat: new download UI, more stable downloads * fix: clippy * fix: only show admin link if user is admin * feat: check for libs before building
53 lines
1.6 KiB
Rust
53 lines
1.6 KiB
Rust
use std::fs;
|
|
|
|
use log::warn;
|
|
|
|
use crate::{
|
|
database::{
|
|
db::borrow_db_mut_checked,
|
|
models::data::{DownloadType, DownloadableMetadata},
|
|
},
|
|
games::{
|
|
downloads::drop_data::{DropData, DROP_DATA_PATH},
|
|
library::set_partially_installed_db,
|
|
},
|
|
};
|
|
|
|
pub fn scan_install_dirs() {
|
|
let mut db_lock = borrow_db_mut_checked();
|
|
for install_dir in db_lock.applications.install_dirs.clone() {
|
|
let Ok(files) = fs::read_dir(install_dir) else {
|
|
continue;
|
|
};
|
|
for game in files.into_iter().flatten() {
|
|
let drop_data_file = game.path().join(DROP_DATA_PATH);
|
|
if !drop_data_file.exists() {
|
|
continue;
|
|
}
|
|
let game_id = game.file_name().into_string().unwrap();
|
|
let Ok(drop_data) = DropData::read(&game.path()) else {
|
|
warn!(
|
|
".dropdata exists for {}, but couldn't read it. is it corrupted?",
|
|
game.file_name().into_string().unwrap()
|
|
);
|
|
continue;
|
|
};
|
|
if db_lock.applications.game_statuses.contains_key(&game_id) {
|
|
continue;
|
|
}
|
|
|
|
let metadata = DownloadableMetadata::new(
|
|
drop_data.game_id,
|
|
Some(drop_data.game_version),
|
|
DownloadType::Game,
|
|
);
|
|
set_partially_installed_db(
|
|
&mut db_lock,
|
|
&metadata,
|
|
drop_data.base_path.to_str().unwrap().to_string(),
|
|
None,
|
|
);
|
|
}
|
|
}
|
|
}
|