mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
fix: set backup progress complete atomically with status revert
Move BackupProgress { complete: true } into the same db.mutate() as the
DesiredStatus revert in the backup transition. Previously these were
separate mutations—the status would revert to Running before progress
showed complete, causing a visible gap in the UI.
This commit is contained in:
@@ -278,22 +278,6 @@ async fn perform_backup(
|
|||||||
timestamp: Utc::now(),
|
timestamp: Utc::now(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
ctx.db
|
|
||||||
.mutate(|db| {
|
|
||||||
if let Some(progress) = db
|
|
||||||
.as_public_mut()
|
|
||||||
.as_server_info_mut()
|
|
||||||
.as_status_info_mut()
|
|
||||||
.as_backup_progress_mut()
|
|
||||||
.transpose_mut()
|
|
||||||
{
|
|
||||||
progress.insert(&id, &BackupProgress { complete: true })?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
})
|
|
||||||
.await
|
|
||||||
.result?;
|
|
||||||
}
|
}
|
||||||
backup_report.insert(
|
backup_report.insert(
|
||||||
id.clone(),
|
id.clone(),
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use futures::future::BoxFuture;
|
|||||||
use futures::{FutureExt, TryFutureExt};
|
use futures::{FutureExt, TryFutureExt};
|
||||||
use rpc_toolkit::yajrc::RpcError;
|
use rpc_toolkit::yajrc::RpcError;
|
||||||
|
|
||||||
|
use crate::db::model::public::BackupProgress;
|
||||||
use crate::disk::mount::filesystem::ReadWrite;
|
use crate::disk::mount::filesystem::ReadWrite;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::rpc_continuations::Guid;
|
use crate::rpc_continuations::Guid;
|
||||||
@@ -29,6 +30,7 @@ impl ServiceActorSeed {
|
|||||||
ErrorKind::Cancelled,
|
ErrorKind::Cancelled,
|
||||||
))
|
))
|
||||||
};
|
};
|
||||||
|
let backup_succeeded = res.is_ok();
|
||||||
let id = &self.id;
|
let id = &self.id;
|
||||||
self.ctx
|
self.ctx
|
||||||
.db
|
.db
|
||||||
@@ -49,7 +51,19 @@ impl ServiceActorSeed {
|
|||||||
} => DesiredStatus::Stopped,
|
} => DesiredStatus::Stopped,
|
||||||
x => x,
|
x => x,
|
||||||
})
|
})
|
||||||
})
|
})?;
|
||||||
|
if backup_succeeded {
|
||||||
|
if let Some(progress) = db
|
||||||
|
.as_public_mut()
|
||||||
|
.as_server_info_mut()
|
||||||
|
.as_status_info_mut()
|
||||||
|
.as_backup_progress_mut()
|
||||||
|
.transpose_mut()
|
||||||
|
{
|
||||||
|
progress.insert(id, &BackupProgress { complete: true })?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.result?;
|
.result?;
|
||||||
|
|||||||
Reference in New Issue
Block a user