Skip to content

Commit

Permalink
[beta] Development build. Update internal & external libraries. Bump …
Browse files Browse the repository at this point in the history
…patch to v20
  • Loading branch information
DIDIRUS4 committed Jan 14, 2024
1 parent 21764a2 commit edec110
Show file tree
Hide file tree
Showing 12 changed files with 247 additions and 133 deletions.
60 changes: 60 additions & 0 deletions theseus/src/api/settings.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Theseus profile management interface

use std::path::{PathBuf, Path};
// use async_recursion::async_recursion;
use tokio::fs;

use io::IOError;
Expand All @@ -23,6 +24,7 @@ pub use crate::{
#[tracing::instrument]
pub async fn get() -> crate::Result<Settings> {
let state = State::get().await?;
state.settings.write().await.opt_out_analytics = true; // Hard disabled analytics in AstralRinth
let settings = state.settings.read().await;
Ok(settings.clone())
}
Expand Down Expand Up @@ -74,6 +76,64 @@ pub async fn set(settings: Settings) -> crate::Result<()> {
Ok(())
}


// #[async_recursion]
// async fn remove_directory_contents(dir_path: &Path) -> std::io::Result<()> {
// let mut read_dir = fs::read_dir(dir_path).await?;
//
// // Process entries
// while let Some(entry) = read_dir.next_entry().await? {
// let entry_path = entry.path();
//
// if entry_path.is_file() {
// fs::remove_file(&entry_path).await?;
// } else if entry_path.is_dir() {
// remove_directory_contents(&entry_path).await?;
// fs::remove_dir(&entry_path).await?;
// }
// }
//
// Ok(())
// }
//
// pub async fn migrate_config_dir(mrPath: PathBuf) -> crate::Result<()> {
// let mut state_write = State::get_write().await?;
// let old_dir = mrPath;
// let new_dir = state_write.directories.config_dir.read().await.clone();
// tracing::info!("mrPath: {}", old_dir.display());
// tracing::info!("arPath: {}", new_dir.display());
//
//
// // Function to move files from the source directory to the destination directory
// async fn move_files(src_dir: &Path, dest_dir: &Path) -> std::io::Result<()> {
// let mut read_dir = tokio::fs::read_dir(src_dir).await?;
// let mut entries = Vec::new();
//
// // Collect entries into a vector
// while let Some(entry) = read_dir.next_entry().await? {
// entries.push(entry);
// }
//
// // Process entries
// for entry in entries {
// let entry_path = entry.path();
// let dest_path = dest_dir.join(entry.file_name());
//
// tokio::fs::rename(entry_path, dest_path).await?;
// }
//
// Ok(())
// }
//
// if new_dir.exists() {
// remove_directory_contents(&new_dir).await?;
// }
//
// move_files(&old_dir, &new_dir).await?;
//
// Ok(())
// }

/// Sets the new config dir, the location of all Theseus data except for the settings.json and caches
/// Takes control of the entire state and blocks until completion
pub async fn set_config_dir(new_config_dir: PathBuf) -> crate::Result<()> {
Expand Down
17 changes: 17 additions & 0 deletions theseus/src/state/dirs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ impl DirectoryInfo {
.or_else(|| Some(dirs::config_dir()?.join("com.modrinth.theseus")))
}

// pub fn get_initial_ar_dir() -> Option<PathBuf> {
// Self::env_path("ASTRALRINTH_DIR")
// .or_else(|| Some(dirs::config_dir()?.join("astralrinth")))
// }

#[inline]
pub fn get_initial_settings_file() -> crate::Result<PathBuf> {
let settings_dir = Self::get_initial_settings_dir().ok_or(
Expand All @@ -53,12 +58,24 @@ impl DirectoryInfo {
),
)?;

// let ar_settings_dir = Self::get_initial_ar_dir().ok_or(
// crate::ErrorKind::FSError(
// "Could not find valid AstralRinth dir".to_string(),
// ),
// )?;

fs::create_dir_all(&settings_dir).map_err(|err| {
crate::ErrorKind::FSError(format!(
"Error creating Theseus config directory: {err}"
))
})?;

// fs::create_dir_all(&ar_settings_dir).map_err(|err| {
// crate::ErrorKind::FSError(format!(
// "Error creating AstralRinth directory: {err}"
// ))
// })?;

// config directory (for instances, etc.)
// by default this is the same as the settings directory
let config_dir = settings.loaded_config_dir.clone().ok_or(
Expand Down
2 changes: 1 addition & 1 deletion theseus/src/state/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl Settings {
native_decorations: false,
default_page: DefaultPage::Home,
developer_mode: false,
opt_out_analytics: false,
opt_out_analytics: true, // Disabled by default in AstralRinth
advanced_rendering: true,
fully_onboarded: rescued, // If we rescued the settings file, we should consider the user fully onboarded

Expand Down
6 changes: 3 additions & 3 deletions theseus_gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "theseus_gui",
"private": true,
"version": "0.6.3",
"patch_version": "19 • Beta",
"patch_version": "20 • Beta",
"development_build": true,
"type": "module",
"scripts": {
Expand All @@ -25,7 +25,7 @@
"qrcode.vue": "^3.4.1",
"tauri-plugin-window-state-api": "github:tauri-apps/tauri-plugin-window-state#v1",
"vite-svg-loader": "^4.0.0",
"vue": "^3.4.5",
"vue": "^3.4.13",
"vue-i18n": "^9.9.0",
"vue-multiselect": "3.0.0-beta.3",
"vue-router": "4.2.1",
Expand All @@ -37,7 +37,7 @@
"@vitejs/plugin-vue": "^4.6.2",
"eslint": "^8.56.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-vue": "^9.19.2",
"eslint-plugin-vue": "^9.20.1",
"prettier": "^2.8.8",
"sass": "^1.69.7",
"vite": "^4.5.1",
Expand Down
Loading

0 comments on commit edec110

Please sign in to comment.