MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / update

Method update

crates/opencode-storage/src/repository.rs:256–331  ·  view source on GitHub ↗
(&self, session: &Session)

Source from the content-addressed store, hash-verified

254 }
255
256 pub async fn update(&self, session: &Session) -> Result<(), DatabaseError> {
257 let summary_diffs = session
258 .summary
259 .as_ref()
260 .and_then(|s| serde_json::to_string(&s.diffs).ok());
261
262 let revert_json = session
263 .revert
264 .as_ref()
265 .and_then(|r| serde_json::to_string(r).ok());
266
267 let permission_json = session
268 .permission
269 .as_ref()
270 .and_then(|p| serde_json::to_string(p).ok());
271
272 let share_url = session.share.as_ref().map(|s| s.url.as_str());
273
274 let usage = session.usage.as_ref();
275
276 sqlx::query(
277 r#"
278 UPDATE sessions SET
279 title = ?, version = ?, share_url = ?,
280 summary_additions = ?, summary_deletions = ?, summary_files = ?, summary_diffs = ?,
281 revert = ?, permission = ?,
282 usage_input_tokens = ?, usage_output_tokens = ?, usage_reasoning_tokens = ?,
283 usage_cache_write_tokens = ?, usage_cache_read_tokens = ?, usage_total_cost = ?,
284 status = ?, updated_at = ?, time_compacting = ?, time_archived = ?
285 WHERE id = ?
286 "#,
287 )
288 .bind(&session.title)
289 .bind(&session.version)
290 .bind(share_url)
291 .bind(
292 session
293 .summary
294 .as_ref()
295 .map(|s| s.additions as i64)
296 .unwrap_or(0),
297 )
298 .bind(
299 session
300 .summary
301 .as_ref()
302 .map(|s| s.deletions as i64)
303 .unwrap_or(0),
304 )
305 .bind(
306 session
307 .summary
308 .as_ref()
309 .map(|s| s.files as i64)
310 .unwrap_or(0),
311 )
312 .bind(summary_diffs)
313 .bind(revert_json)

Callers

nothing calls this directly

Calls 3

status_to_stringFunction · 0.85
as_strMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected