fix(io): remove released edit lock files

Closes #579
This commit is contained in:
Hakan Seven committed 2026-07-30 11:54:08 +03:00
1 parent 2688ffbd6b
commit 284d6ef517
1 file changed
+15 -1
+15 -1
View File
@@ -134,7 +134,13 @@ impl EditLease {
);
let _ = sidecar.flush();
let (drawing, platform_warning) = acquire_drawing_lock(&canonical)?;
let (drawing, platform_warning) = match acquire_drawing_lock(&canonical) {
Ok(lock) => lock,
Err(error) => {
let _ = std::fs::remove_file(&lock_path);
return Err(error);
}
};
Ok(Self {
_sidecar: sidecar,
drawing,
@@ -162,6 +168,14 @@ impl EditLease {
}
}
impl Drop for EditLease {
fn drop(&mut self) {
// Remove the path while the exclusive sidecar lock is still held so
// another editor cannot acquire it during cleanup.
let _ = std::fs::remove_file(&self.lock_path);
}
}
fn acquire_drawing_lock(path: &Path) -> Result<(Option<File>, Option<String>), EditLeaseError> {
let drawing = match OpenOptions::new().read(true).write(true).open(path) {
Ok(file) => file,