Skip to content

Commit

Permalink
Upgrading (#354)
Browse files Browse the repository at this point in the history
* fixed no download bug

* draft

* Working version

* minor improvements

* cicd fix

* merge conflicts

* fixed major merge confusion

* more conflicts, reformatting

* fixed random bugs found

* added second repair option to avoid confusion
  • Loading branch information
thesuzerain authored Jul 27, 2023
1 parent 70aaf6e commit 21ae310
Show file tree
Hide file tree
Showing 24 changed files with 812 additions and 301 deletions.
84 changes: 40 additions & 44 deletions theseus/src/api/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,19 @@ impl Logs {

#[tracing::instrument]
pub async fn get_logs(
profile_uuid: uuid::Uuid,
profile_path: ProfilePathId,
clear_contents: Option<bool>,
) -> crate::Result<Vec<Logs>> {
let state = State::get().await?;
let profile_path = if let Some(p) =
crate::profile::get_by_uuid(profile_uuid, None).await?
{
p.profile_id()
} else {
return Err(crate::ErrorKind::UnmanagedProfileError(
profile_uuid.to_string(),
)
.into());
};
let profile_path =
if let Some(p) = crate::profile::get(&profile_path, None).await? {
p.profile_id()
} else {
return Err(crate::ErrorKind::UnmanagedProfileError(
profile_path.to_string(),
)
.into());
};

let logs_folder = state.directories.profile_logs_dir(&profile_path).await?;
let mut logs = Vec::new();
Expand Down Expand Up @@ -77,19 +76,18 @@ pub async fn get_logs(

#[tracing::instrument]
pub async fn get_logs_by_datetime(
profile_uuid: uuid::Uuid,
profile_path: ProfilePathId,
datetime_string: String,
) -> crate::Result<Logs> {
let profile_path = if let Some(p) =
crate::profile::get_by_uuid(profile_uuid, None).await?
{
p.profile_id()
} else {
return Err(crate::ErrorKind::UnmanagedProfileError(
profile_uuid.to_string(),
)
.into());
};
let profile_path =
if let Some(p) = crate::profile::get(&profile_path, None).await? {
p.profile_id()
} else {
return Err(crate::ErrorKind::UnmanagedProfileError(
profile_path.to_string(),
)
.into());
};
Ok(Logs {
output: Some(
get_output_by_datetime(&profile_path, &datetime_string).await?,
Expand All @@ -111,17 +109,16 @@ pub async fn get_output_by_datetime(
}

#[tracing::instrument]
pub async fn delete_logs(profile_uuid: uuid::Uuid) -> crate::Result<()> {
let profile_path = if let Some(p) =
crate::profile::get_by_uuid(profile_uuid, None).await?
{
p.profile_id()
} else {
return Err(crate::ErrorKind::UnmanagedProfileError(
profile_uuid.to_string(),
)
.into());
};
pub async fn delete_logs(profile_path: ProfilePathId) -> crate::Result<()> {
let profile_path =
if let Some(p) = crate::profile::get(&profile_path, None).await? {
p.profile_id()
} else {
return Err(crate::ErrorKind::UnmanagedProfileError(
profile_path.to_string(),
)
.into());
};

let state = State::get().await?;
let logs_folder = state.directories.profile_logs_dir(&profile_path).await?;
Expand All @@ -139,19 +136,18 @@ pub async fn delete_logs(profile_uuid: uuid::Uuid) -> crate::Result<()> {

#[tracing::instrument]
pub async fn delete_logs_by_datetime(
profile_uuid: uuid::Uuid,
profile_path: ProfilePathId,
datetime_string: &str,
) -> crate::Result<()> {
let profile_path = if let Some(p) =
crate::profile::get_by_uuid(profile_uuid, None).await?
{
p.profile_id()
} else {
return Err(crate::ErrorKind::UnmanagedProfileError(
profile_uuid.to_string(),
)
.into());
};
let profile_path =
if let Some(p) = crate::profile::get(&profile_path, None).await? {
p.profile_id()
} else {
return Err(crate::ErrorKind::UnmanagedProfileError(
profile_path.to_string(),
)
.into());
};

let state = State::get().await?;
let logs_folder = state.directories.profile_logs_dir(&profile_path).await?;
Expand Down
5 changes: 2 additions & 3 deletions theseus/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pub mod metadata;
pub mod pack;
pub mod process;
pub mod profile;
pub mod profile_create;
pub mod safety;
pub mod settings;
pub mod tags;
Expand All @@ -26,8 +25,8 @@ pub mod prelude {
data::*,
event::CommandPayload,
jre, metadata, pack, process,
profile::{self, Profile},
profile_create, settings,
profile::{self, create, Profile},
settings,
state::JavaGlobals,
state::{ProfilePathId, ProjectPathId},
util::{
Expand Down
2 changes: 1 addition & 1 deletion theseus/src/api/pack/import/atlauncher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ async fn import_atlauncher_unmanaged(
let game_version = atinstance.id;

let loader_version = if mod_loader != ModLoader::Vanilla {
crate::profile_create::get_loader_version_from_loader(
crate::profile::create::get_loader_version_from_loader(
game_version.clone(),
mod_loader,
Some(atinstance.launcher.loader_version.version.clone()),
Expand Down
2 changes: 1 addition & 1 deletion theseus/src/api/pack/import/curseforge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub async fn import_curseforge(
let mod_loader = mod_loader.unwrap_or(ModLoader::Vanilla);

let loader_version = if mod_loader != ModLoader::Vanilla {
crate::profile_create::get_loader_version_from_loader(
crate::profile::create::get_loader_version_from_loader(
game_version.clone(),
mod_loader,
loader_version,
Expand Down
2 changes: 1 addition & 1 deletion theseus/src/api/pack/import/gdlauncher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub async fn import_gdlauncher(
let loader_version = config.loader.loader_version;

let loader_version = if mod_loader != ModLoader::Vanilla {
crate::profile_create::get_loader_version_from_loader(
crate::profile::create::get_loader_version_from_loader(
game_version.clone(),
mod_loader,
loader_version,
Expand Down
2 changes: 2 additions & 0 deletions theseus/src/api/pack/import/mmc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ pub struct MMCInstance {
#[serde(deserialize_with = "deserialize_optional_bool")]
pub managed_pack: Option<bool>,

#[serde(rename = "ManagedPackID")]
pub managed_pack_id: Option<String>,
pub managed_pack_type: Option<MMCManagedPackType>,
#[serde(rename = "ManagedPackVersionID")]
pub managed_pack_version_id: Option<String>,
pub managed_pack_version_name: Option<String>,

Expand Down
5 changes: 5 additions & 0 deletions theseus/src/api/pack/import/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize};

use crate::{
prelude::ProfilePathId,
state::Profiles,
util::{fetch, io},
};

Expand Down Expand Up @@ -112,6 +113,10 @@ pub async fn import_instance(
.into());
}
}

// Check existing managed packs for potential updates
tokio::task::spawn(Profiles::update_modrinth_versions());

tracing::debug!("Completed import.");
Ok(())
}
Expand Down
3 changes: 2 additions & 1 deletion theseus/src/api/pack/install_from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ impl Default for CreatePackProfile {
}
}

#[derive(Clone)]
pub struct CreatePack {
pub file: bytes::Bytes,
pub description: CreatePackDescription,
Expand Down Expand Up @@ -337,7 +338,7 @@ pub async fn set_profile_information(

let mod_loader = mod_loader.unwrap_or(ModLoader::Vanilla);
let loader_version = if mod_loader != ModLoader::Vanilla {
crate::profile_create::get_loader_version_from_loader(
crate::profile::create::get_loader_version_from_loader(
game_version.clone(),
mod_loader,
loader_version.cloned(),
Expand Down
Loading

0 comments on commit 21ae310

Please sign in to comment.