You've already forked AstralRinth
forked from didirus/AstralRinth
debugging; box pinning (#101)
This commit is contained in:
@@ -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;
|
||||
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())
|
||||
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
|
||||
|
||||
@@ -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?;
|
||||
Box::pin(async move {
|
||||
let state = Self::get().await?;
|
||||
let sync_settings = async {
|
||||
let state = Arc::clone(&state);
|
||||
|
||||
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?
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
let sync_profiles = async {
|
||||
let state = Arc::clone(&state);
|
||||
tokio::spawn(async move {
|
||||
let profiles = state.profiles.read().await;
|
||||
|
||||
tokio::spawn(async move {
|
||||
let profiles = state.profiles.read().await;
|
||||
profiles.sync().await?;
|
||||
Ok::<_, crate::Error>(())
|
||||
})
|
||||
.await?
|
||||
};
|
||||
|
||||
profiles.sync().await?;
|
||||
Ok::<_, crate::Error>(())
|
||||
})
|
||||
.await?
|
||||
};
|
||||
|
||||
tokio::try_join!(sync_settings, sync_profiles)?;
|
||||
|
||||
Ok(())
|
||||
tokio::try_join!(sync_settings, sync_profiles)?;
|
||||
Ok(())
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
/// Reset semaphores to default values
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user