[edge] Epoch floor: an unreadable or corrupt floor refuses share links instead of resetting to 0; directory fsync'ed after the write

This commit is contained in:
2026-11-07 19:41:53 +01:00
parent cbb3e41ca7
commit 83b7b3b7d6
2 changed files with 60 additions and 7 deletions
+25
View File
@@ -531,4 +531,29 @@ mod unix {
.await;
assert_eq!(e.get(HOST, "/", Some(&fresh_cookie)).await.status, 302);
}
#[tokio::test(flavor = "multi_thread")]
async fn an_unreadable_epoch_floor_refuses_share_links() {
let mut e = env().await;
let t = link(HOST, 15, "/", now() + 3600, None);
let cookie = share_cookie(&e.get(HOST, &format!("/?share={t}"), None).await);
assert_eq!(e.get(HOST, "/", Some(&cookie)).await.status, 200);
std::fs::write(e.edge.dir.join("state/share-epoch-floor"), "garbage").unwrap();
e.edge.restart();
assert_eq!(
e.get(HOST, "/", Some(&cookie)).await.status,
302,
"fails closed"
);
let r = e
.edge
.admin("POST", "/v1/share-revocations/reload", None)
.await;
assert_eq!(r.status, 422, "{}", r.text);
assert!(e.edge.stderr().contains("share-epoch-floor"));
// A missing floor is simply 0.
std::fs::remove_file(e.edge.dir.join("state/share-epoch-floor")).unwrap();
e.edge.restart();
assert_eq!(e.get(HOST, "/", Some(&cookie)).await.status, 200);
}
}