mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-16 09:41:17 +10:00
QoL Download Manager (#108)
* feat: retry specific download errors * fix: potential fix for cmd window on Windows * feat: add disk space check for download * fix: update game fix formatting * fix: clippy
This commit is contained in:
27
src-tauri/src/process/utils.rs
Normal file
27
src-tauri/src/process/utils.rs
Normal file
@ -0,0 +1,27 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use futures_lite::io;
|
||||
use sysinfo::{Disk, DiskRefreshKind, Disks};
|
||||
|
||||
use crate::error::application_download_error::ApplicationDownloadError;
|
||||
|
||||
pub fn get_disk_available(mount_point: PathBuf) -> Result<u64, ApplicationDownloadError> {
|
||||
let disks = Disks::new_with_refreshed_list_specifics(DiskRefreshKind::nothing().with_storage());
|
||||
|
||||
let mut disk_iter = disks.into_iter().collect::<Vec<&Disk>>();
|
||||
disk_iter.sort_by(|a, b| {
|
||||
b.mount_point()
|
||||
.to_string_lossy()
|
||||
.len()
|
||||
.cmp(&a.mount_point().to_string_lossy().len())
|
||||
});
|
||||
|
||||
for disk in disk_iter {
|
||||
if mount_point.starts_with(disk.mount_point()) {
|
||||
return Ok(disk.available_space());
|
||||
}
|
||||
}
|
||||
Err(ApplicationDownloadError::IoError(io::Error::other(
|
||||
"could not find disk of path",
|
||||
).kind()))
|
||||
}
|
||||
Reference in New Issue
Block a user