Skip to content

Commit c6fddf3

Browse files
fix(storage): sync preserved recovery set on Windows
1 parent 50fbdd2 commit c6fddf3

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/doctor/tests.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,11 @@ fn database_recovery_guidance_names_the_preserved_recovery_set() {
241241

242242
let branch_db = PathBuf::from("/profile/projects/proj_test/branches/feature.db");
243243
let branch_guidance = database_recovery_guidance(&branch_db);
244-
assert!(branch_guidance.contains("/profile/projects/proj_test/dirty"));
245-
assert!(branch_guidance.contains("/profile/projects/proj_test/sessions.db"));
246-
assert!(!branch_guidance.contains("/branches/sessions.db"));
244+
let branches_root = branch_db.parent().unwrap();
245+
let data_root = branches_root.parent().unwrap();
246+
assert!(branch_guidance.contains(&data_root.join("dirty").display().to_string()));
247+
assert!(branch_guidance.contains(&data_root.join("sessions.db").display().to_string()));
248+
assert!(!branch_guidance.contains(&branches_root.join("sessions.db").display().to_string()));
247249
}
248250

249251
#[tokio::test]

src/tracedecay/lifecycle.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,11 @@ fn preserve_corrupt_branch_store(store_layout: &StoreLayout, db_path: &Path) ->
12071207
),
12081208
});
12091209
}
1210-
std::fs::File::open(&target)
1210+
// Windows `FlushFileBuffers` requires a write handle, so a read-only
1211+
// open would fail the durability sync with "access is denied".
1212+
std::fs::OpenOptions::new()
1213+
.write(true)
1214+
.open(&target)
12111215
.and_then(|file| file.sync_all())
12121216
.map_err(|error| TraceDecayError::Config {
12131217
message: format!(

0 commit comments

Comments
 (0)