fix #14740: always clean up deepscript jobs and upload copies
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -360,6 +360,20 @@ impl Store {
|
||||
Ok(jobs)
|
||||
}
|
||||
|
||||
/// Calls that still have remote jobs on record (their delete failed or
|
||||
/// never ran), ordered by id.
|
||||
pub fn calls_with_remote_jobs(&self) -> Result<Vec<CallId>> {
|
||||
let conn = self.conn.lock().unwrap();
|
||||
let mut stmt =
|
||||
conn.prepare("SELECT DISTINCT call_id FROM remote_jobs ORDER BY call_id ASC")?;
|
||||
let mut rows = stmt.query([])?;
|
||||
let mut ids = Vec::new();
|
||||
while let Some(row) = rows.next()? {
|
||||
ids.push(row.get(0)?);
|
||||
}
|
||||
Ok(ids)
|
||||
}
|
||||
|
||||
pub fn clear_remote_jobs(&self, id: CallId) -> Result<()> {
|
||||
let conn = self.conn.lock().unwrap();
|
||||
conn.execute("DELETE FROM remote_jobs WHERE call_id = ?1", params![id])?;
|
||||
@@ -822,4 +836,27 @@ mod tests {
|
||||
assert_eq!(store.speaker_names(id).unwrap(), BTreeMap::new());
|
||||
assert_eq!(store.remote_jobs(id).unwrap(), Vec::new());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn calls_with_remote_jobs_lists_each_call_once() {
|
||||
let store = Store::open_in_memory().unwrap();
|
||||
let call = |app| {
|
||||
store
|
||||
.create_call(app, Local::now(), Path::new(""), Path::new(""))
|
||||
.unwrap()
|
||||
};
|
||||
let (a, _without_jobs, c) = (call("a"), call("b"), call("c"));
|
||||
assert_eq!(
|
||||
store.calls_with_remote_jobs().unwrap(),
|
||||
Vec::<CallId>::new()
|
||||
);
|
||||
|
||||
store.record_remote_job(c, "mic", "job-c").unwrap();
|
||||
store.record_remote_job(a, "mic", "job-a1").unwrap();
|
||||
store.record_remote_job(a, "out", "job-a2").unwrap();
|
||||
assert_eq!(store.calls_with_remote_jobs().unwrap(), vec![a, c]);
|
||||
|
||||
store.clear_remote_jobs(a).unwrap();
|
||||
assert_eq!(store.calls_with_remote_jobs().unwrap(), vec![c]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user