Repository navigation
Keep Drive permission expiry across delivery retry #753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1366,6 +1366,7 @@ mod failure { | |
| refuse_revoke: Mutex<bool>, | ||
| refuse_object_delete: Mutex<bool>, | ||
| calls: Mutex<Vec<String>>, | ||
| pub(crate) shared_expires_at: Mutex<Vec<i64>>, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is still capped at the 3822 lines
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trimmed |
||
| } | ||
|
|
||
| impl FakeDelivery { | ||
|
|
@@ -1405,11 +1406,12 @@ mod failure { | |
| &'a self, | ||
| _drive_file_id: &'a str, | ||
| _recipient_email: &'a str, | ||
| _expires_at: i64, | ||
| expires_at: i64, | ||
| ) -> std::pin::Pin<Box<dyn std::future::Future<Output = Result<String, String>> + Send + 'a>> | ||
| { | ||
| Box::pin(async move { | ||
| self.calls.lock().unwrap().push("share".to_string()); | ||
| self.shared_expires_at.lock().unwrap().push(expires_at); | ||
| if let Some(path) = self.preempt_share.lock().unwrap().as_ref() { | ||
| rusqlite::Connection::open(path) | ||
| .unwrap() | ||
|
|
@@ -2239,7 +2241,7 @@ mod failure { | |
| let (file, permission): (Option<String>, Option<String>) = scratch | ||
| .open() | ||
| .query_row( | ||
| "SELECT drive_file_id, drive_permission_id FROM recordings WHERE id = 'rec-1'", | ||
| "SELECT drive_file_id, drive_permission_id FROM recordings WHERE id = 'rec-1' AND expires_at IS NULL", | ||
| [], | ||
| |row| Ok((row.get(0)?, row.get(1)?)), | ||
| ) | ||
|
|
@@ -2707,19 +2709,16 @@ mod failure { | |
| Some("operator"), | ||
| "\"expiry\" would say the deadline came, and it did not" | ||
| ); | ||
|
|
||
| // An id nobody has is a failure rather than a quiet success. | ||
| let missing = std::process::Command::new("sh") | ||
| .arg("./scripts/recording-cleanup.sh") | ||
| .args([ | ||
| "--db", | ||
| scratch.path().to_str().unwrap(), | ||
| "--expire", | ||
| "rec-nobody", | ||
| ]) | ||
| .output() | ||
| .unwrap(); | ||
| assert!(!missing.status.success()); | ||
| let (db, s) = (scratch.path().display(), scratch.open()); | ||
| let q = ",state='cleanup_failed',error='drive_failed',deleted_at=NULL,deleted_by=NULL,room_name='',recipient_email=''"; | ||
| let run = |sql: &str, a: &str| { | ||
| let _ = s.execute_batch(&format!("UPDATE recordings SET id=id{sql}")); | ||
| let cmd = format!("./scripts/recording-cleanup.sh --db {db} --now {a}"); | ||
| let o = std::process::Command::new("sh").args(["-c", &cmd]).output(); | ||
| o.is_ok_and(|o| o.status.success() && (a.ends_with('1') || o.stdout == b"rec-1\n")) | ||
| }; | ||
| assert!(run(q, "9") && !run(",state='failed'", "1000") && run("", "87400")); | ||
| assert!(!run("", "9 --expire x") && run("", "9 --expire rec-1") && run("", "9")); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| } | ||
|
|
||
| #[tokio::test] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
CASE WHEN state NOT IN ('transferring', 'failed') OR deleted_by = 'operator' THEN expires_at ENDis written again word for word inreplay_viewinsrc/recording/replay.rs, anddue_for_deletionbelow states the same rule a third way (state = 'ready' OR deleted_by = 'operator'). The readers already drifted apart once on this PR (the thread onreplay.rsabout operator-expiredfailedrows), so the next change to which rows show a deadline has to find all three. One shared SQL constant used in bothSELECTs, withdue_for_deletioneither using the same expression or carrying a comment that names where the rule lives, would keep them in step.