Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debugging; box pinning #101

Merged
merged 1 commit into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,28 @@
},
"args": [],
"cwd": "${workspaceFolder}"
}
},
{
"type": "lldb",
"request": "launch",
"name": "Tauri Development Debug",
"cargo": {
"args": [
"build",
"--manifest-path=./theseus_gui/src-tauri/Cargo.toml",
"--no-default-features"
]
},
"preLaunchTask": "ui:dev"
},
{
"type": "lldb",
"request": "launch",
"name": "Tauri Production Debug",
"cargo": {
"args": ["build", "--release", "--manifest-path=.theseus_gui/src-tauri/Cargo.toml"]
},
"preLaunchTask": "ui:build"
}
]
}
32 changes: 32 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "ui:dev",
"type": "shell",
// `dev` keeps running in the background
// ideally you should also configure a `problemMatcher`
// see https://code.visualstudio.com/docs/editor/tasks#_can-a-background-task-be-used-as-a-prelaunchtask-in-launchjson
"isBackground": true,
// change this to your `beforeDevCommand`:
"command": "yarn",
"args": ["dev"],
"options": {
"cwd": "${workspaceFolder}/theseus_gui"
}
},
{
"label": "ui:build",
"type": "shell",
// change this to your `beforeBuildCommand`:
"command": "yarn",
"args": ["build"],
"options": {
"cwd": "${workspaceFolder}/theseus_gui"
}
}
]

}
39 changes: 22 additions & 17 deletions theseus/src/api/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,24 +89,29 @@ pub async fn list() -> crate::Result<std::collections::HashMap<PathBuf, Profile>
/// Query + sync profile's projects with the UI from the FS
#[tracing::instrument]
pub async fn sync(path: &Path) -> crate::Result<()> {
let state = State::get().await?;
let result = {
let mut profiles: tokio::sync::RwLockWriteGuard<
crate::state::Profiles,
> = state.profiles.write().await;

if let Some(profile) = profiles.0.get_mut(path) {
profile.sync().await?;
Ok(())
} else {
Err(crate::ErrorKind::UnmanagedProfileError(
path.display().to_string(),
)
.as_error())
Box::pin({
async move {
let state = State::get().await?;
let result = {
let mut profiles: tokio::sync::RwLockWriteGuard<
crate::state::Profiles,
> = state.profiles.write().await;

if let Some(profile) = profiles.0.get_mut(path) {
profile.sync().await?;
Ok(())
} else {
Err(crate::ErrorKind::UnmanagedProfileError(
path.display().to_string(),
)
.as_error())
}
};
State::sync().await?;
result
}
};
State::sync().await?;
result
})
.await
}

/// Installs/Repairs a profile
Expand Down
57 changes: 29 additions & 28 deletions theseus/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,34 +138,35 @@ impl State {
#[tracing::instrument]
/// Synchronize in-memory state with persistent state
pub async fn sync() -> crate::Result<()> {
let state = Self::get().await?;

let sync_settings = async {
let state = Arc::clone(&state);

tokio::spawn(async move {
let reader = state.settings.read().await;
reader.sync(&state.directories.settings_file()).await?;
Ok::<_, crate::Error>(())
})
.await?
};

let sync_profiles = async {
let state = Arc::clone(&state);

tokio::spawn(async move {
let profiles = state.profiles.read().await;

profiles.sync().await?;
Ok::<_, crate::Error>(())
})
.await?
};

tokio::try_join!(sync_settings, sync_profiles)?;

Ok(())
Box::pin(async move {
let state = Self::get().await?;
let sync_settings = async {
let state = Arc::clone(&state);

tokio::spawn(async move {
let reader = state.settings.read().await;
reader.sync(&state.directories.settings_file()).await?;
Ok::<_, crate::Error>(())
})
.await?
};

let sync_profiles = async {
let state = Arc::clone(&state);

tokio::spawn(async move {
let profiles = state.profiles.read().await;

profiles.sync().await?;
Ok::<_, crate::Error>(())
})
.await?
};

tokio::try_join!(sync_settings, sync_profiles)?;
Ok(())
})
.await
}

/// Reset semaphores to default values
Expand Down
8 changes: 1 addition & 7 deletions theseus/src/state/projects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,7 @@ pub async fn infer_data_from_files(
.filter(|x| x.team_id == project.team)
.cloned()
.collect::<Vec<_>>(),
update_version: if let Some(val) =
update_versions.get(&hash)
{
Some(Box::new(val.clone()))
} else {
None
},
update_version: update_versions.get(&hash).map(|val| Box::new(val.clone())),

incompatible: !version.loaders.contains(
&profile
Expand Down