mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2026-01-30 19:15:17 +01:00
* feat: depot api downloads * feat: frontend fixes and experimental webview store * feat: sync downloader * feat: cleanup and fixes * feat: encrypted database and fixed resuming * feat: launch option selector * fix: autostart when no options * fix: clippy * fix: clippy x2 * feat: executor launch * feat: executor launch * feat: not installed error handling * feat: better offline handling * feat: dependency popup * fix: cancelation and resuming issues * feat: dedup by platform * feat: new ui for additional components and fix dl manager clog * feat: auto-queue dependencies * feat: depot scanning and ranking * feat: new library fetching stack * In-app store page (Windows + macOS) (#176) * feat: async store loading * feat: fix overscroll behaviour * fix: query params in server protocol * fix: clippy
37 lines
1.1 KiB
Rust
37 lines
1.1 KiB
Rust
use std::{
|
|
path::PathBuf,
|
|
sync::{Arc, LazyLock},
|
|
};
|
|
|
|
use keyring::Entry;
|
|
use log::info;
|
|
|
|
use crate::interface::{DatabaseInterface};
|
|
|
|
pub static DB: LazyLock<DatabaseInterface> = LazyLock::new(DatabaseInterface::set_up_database);
|
|
|
|
#[cfg(not(debug_assertions))]
|
|
static DATA_ROOT_PREFIX: &str = "drop";
|
|
#[cfg(debug_assertions)]
|
|
static DATA_ROOT_PREFIX: &str = "drop-debug";
|
|
|
|
pub static DATA_ROOT_DIR: LazyLock<Arc<PathBuf>> = LazyLock::new(|| {
|
|
Arc::new(
|
|
dirs::data_dir()
|
|
.expect("Failed to get data dir")
|
|
.join(DATA_ROOT_PREFIX),
|
|
)
|
|
});
|
|
|
|
pub(crate) static KEY_IV: LazyLock<([u8; 16], [u8; 16])> = LazyLock::new(|| {
|
|
let entry = Entry::new("drop", "database_key").expect("failed to open keyring");
|
|
let mut key = entry.get_secret().unwrap_or_else(|_| {
|
|
let mut buffer = [0u8; 32];
|
|
rand::fill(&mut buffer);
|
|
entry.set_secret(&buffer).expect("failed to save key");
|
|
info!("created new database key");
|
|
buffer.to_vec()
|
|
});
|
|
let new = key.split_off(16);
|
|
(new.try_into().expect("failed to extract key"), key.try_into().expect("failed to extract iv"))
|
|
}); |