Reset workspace cleanup timer at diff view and IDE open (#1654)
* Add workspace.touch to reset cleanup timer at diff view and ide open * Touch at ensure_container_exists, rm comments
This commit is contained in:
12
crates/db/.sqlx/query-2a57b702e52b3cc9bdbc361267985958b11d4493b01a9ab8daedf5d951422897.json
generated
Normal file
12
crates/db/.sqlx/query-2a57b702e52b3cc9bdbc361267985958b11d4493b01a9ab8daedf5d951422897.json
generated
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"db_name": "SQLite",
|
||||||
|
"query": "UPDATE workspaces SET updated_at = datetime('now', 'subsec') WHERE id = ?",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "2a57b702e52b3cc9bdbc361267985958b11d4493b01a9ab8daedf5d951422897"
|
||||||
|
}
|
||||||
@@ -223,6 +223,18 @@ impl Workspace {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Update the workspace's updated_at timestamp to prevent cleanup.
|
||||||
|
/// Call this when the workspace is accessed (e.g., opened in editor).
|
||||||
|
pub async fn touch(pool: &SqlitePool, workspace_id: Uuid) -> Result<(), sqlx::Error> {
|
||||||
|
sqlx::query!(
|
||||||
|
"UPDATE workspaces SET updated_at = datetime('now', 'subsec') WHERE id = ?",
|
||||||
|
workspace_id
|
||||||
|
)
|
||||||
|
.execute(pool)
|
||||||
|
.await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn find_by_id(pool: &SqlitePool, id: Uuid) -> Result<Option<Self>, sqlx::Error> {
|
pub async fn find_by_id(pool: &SqlitePool, id: Uuid) -> Result<Option<Self>, sqlx::Error> {
|
||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
Workspace,
|
Workspace,
|
||||||
|
|||||||
@@ -968,6 +968,7 @@ impl ContainerService for LocalContainerService {
|
|||||||
&self,
|
&self,
|
||||||
workspace: &Workspace,
|
workspace: &Workspace,
|
||||||
) -> Result<ContainerRef, ContainerError> {
|
) -> Result<ContainerRef, ContainerError> {
|
||||||
|
Workspace::touch(&self.db.pool, workspace.id).await?;
|
||||||
let repositories =
|
let repositories =
|
||||||
WorkspaceRepo::find_repos_for_workspace(&self.db.pool, workspace.id).await?;
|
WorkspaceRepo::find_repos_for_workspace(&self.db.pool, workspace.id).await?;
|
||||||
|
|
||||||
|
|||||||
@@ -245,6 +245,8 @@ pub async fn stream_task_attempt_diff_ws(
|
|||||||
Extension(workspace): Extension<Workspace>,
|
Extension(workspace): Extension<Workspace>,
|
||||||
State(deployment): State<DeploymentImpl>,
|
State(deployment): State<DeploymentImpl>,
|
||||||
) -> impl IntoResponse {
|
) -> impl IntoResponse {
|
||||||
|
let _ = Workspace::touch(&deployment.db().pool, workspace.id).await;
|
||||||
|
|
||||||
let stats_only = params.stats_only;
|
let stats_only = params.stats_only;
|
||||||
ws.on_upgrade(move |socket| async move {
|
ws.on_upgrade(move |socket| async move {
|
||||||
if let Err(e) = handle_task_attempt_diff_ws(socket, deployment, workspace, stats_only).await
|
if let Err(e) = handle_task_attempt_diff_ws(socket, deployment, workspace, stats_only).await
|
||||||
@@ -520,6 +522,9 @@ pub async fn open_task_attempt_in_editor(
|
|||||||
.container()
|
.container()
|
||||||
.ensure_container_exists(&workspace)
|
.ensure_container_exists(&workspace)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
Workspace::touch(&deployment.db().pool, workspace.id).await?;
|
||||||
|
|
||||||
let workspace_path = Path::new(&container_ref);
|
let workspace_path = Path::new(&container_ref);
|
||||||
|
|
||||||
// For single-repo projects, open from the repo directory
|
// For single-repo projects, open from the repo directory
|
||||||
|
|||||||
Reference in New Issue
Block a user