Unfuck the file system
This commit is contained in:
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -815,6 +815,12 @@ dependencies = [
|
|||||||
"pkg-config",
|
"pkg-config",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fs_extra"
|
||||||
|
version = "1.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures"
|
name = "futures"
|
||||||
version = "0.3.30"
|
version = "0.3.30"
|
||||||
@ -3173,6 +3179,7 @@ dependencies = [
|
|||||||
name = "workshop_uploader"
|
name = "workshop_uploader"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"fs_extra",
|
||||||
"iced",
|
"iced",
|
||||||
"image",
|
"image",
|
||||||
"native-dialog",
|
"native-dialog",
|
||||||
|
@ -15,6 +15,7 @@ iced = "0.6"
|
|||||||
native-dialog = "0.6.3"
|
native-dialog = "0.6.3"
|
||||||
image = "0.24.7"
|
image = "0.24.7"
|
||||||
open = "5.1.2"
|
open = "5.1.2"
|
||||||
|
fs_extra = "1.3.0"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
winres = "0.1.12"
|
winres = "0.1.12"
|
||||||
|
@ -5,6 +5,7 @@ use std::sync::{atomic::AtomicUsize, atomic::Ordering, Arc};
|
|||||||
use std::thread::Thread;
|
use std::thread::Thread;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use steamworks::{Client, PublishedFileId, QueryResult, QueryResults, SingleClient, SteamError};
|
use steamworks::{Client, PublishedFileId, QueryResult, QueryResults, SingleClient, SteamError};
|
||||||
|
use std::fs;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct SingleClientExecutor {
|
pub struct SingleClientExecutor {
|
||||||
@ -198,6 +199,21 @@ impl WorkshopClient {
|
|||||||
item_id: PublishedFileId,
|
item_id: PublishedFileId,
|
||||||
item_info: ItemInfo,
|
item_info: ItemInfo,
|
||||||
) -> Result<(PublishedFileId, bool), SteamError> {
|
) -> Result<(PublishedFileId, bool), SteamError> {
|
||||||
|
let temp_dir = std::env::temp_dir(); // Get the temporary directory
|
||||||
|
let temp_folder = temp_dir.join("wani_workshop_folder"); // Create a specific folder within temporary directory
|
||||||
|
let full_folder = temp_folder.join("mods");
|
||||||
|
|
||||||
|
// Create the folders if they doesn't exist
|
||||||
|
if !temp_folder.exists() {
|
||||||
|
let _ = fs::create_dir(&temp_folder);
|
||||||
|
}
|
||||||
|
if !full_folder.exists() {
|
||||||
|
let _ = fs::create_dir(&full_folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
// // Copy the contents of the target folder to the temporary folder
|
||||||
|
let _ = fs_extra::dir::copy(&item_info.target_folder, &full_folder, &fs_extra::dir::CopyOptions::new());
|
||||||
|
|
||||||
let rx = {
|
let rx = {
|
||||||
let app_id = self.steam_client.utils().app_id();
|
let app_id = self.steam_client.utils().app_id();
|
||||||
|
|
||||||
@ -212,7 +228,7 @@ impl WorkshopClient {
|
|||||||
.ugc()
|
.ugc()
|
||||||
.start_item_update(app_id, item_id)
|
.start_item_update(app_id, item_id)
|
||||||
.title(item_info.name.as_str())
|
.title(item_info.name.as_str())
|
||||||
.content_path(&item_info.target_folder);
|
.content_path(&temp_folder); // Set the temporary folder as the content path
|
||||||
|
|
||||||
if item_info.preview_image.exists() {
|
if item_info.preview_image.exists() {
|
||||||
update_handle = update_handle.preview_path(&item_info.preview_image)
|
update_handle = update_handle.preview_path(&item_info.preview_image)
|
||||||
@ -227,9 +243,14 @@ impl WorkshopClient {
|
|||||||
rx
|
rx
|
||||||
};
|
};
|
||||||
|
|
||||||
rx.await
|
let result = rx.await
|
||||||
.map_err(|iced::futures::channel::oneshot::Canceled| SteamError::Cancelled)
|
.map_err(|iced::futures::channel::oneshot::Canceled| SteamError::Cancelled)
|
||||||
.and_then(|x| x)
|
.and_then(|x| x);
|
||||||
|
|
||||||
|
// Clear the temporary folder after the upload is done
|
||||||
|
let _ = std::fs::remove_dir_all(&full_folder);
|
||||||
|
|
||||||
|
Ok(result?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user