Try to remove files before marking for deletion
You know, it might just work...
This commit is contained in:
parent
1a6c6b8f9d
commit
8c7e71127f
1 changed files with 19 additions and 7 deletions
|
@ -465,8 +465,20 @@ module Make
|
||||||
Ok ()
|
Ok ()
|
||||||
| Error e -> Error (`Write_error e)
|
| Error e -> Error (`Write_error e)
|
||||||
else
|
else
|
||||||
|
(* if the checksums mismatch we want to delete the file. We are only
|
||||||
|
able to do so if it was the latest created file, so we expect and
|
||||||
|
error. Ideally, we want to match for `Append_only or other errors *)
|
||||||
|
KV.remove t.dev source >>= function
|
||||||
|
| Ok () ->
|
||||||
|
Logs.info (fun m -> m "Removed %a" Mirage_kv.Key.pp source);
|
||||||
|
Lwt_result.fail (`Bad_checksum (hash, csum))
|
||||||
|
| Error e ->
|
||||||
|
Logs.debug (fun m -> m "Failed to remove %a: %a"
|
||||||
|
Mirage_kv.Key.pp source KV.pp_write_error e);
|
||||||
|
(* we failed to delete the file so we mark it for deletion *)
|
||||||
let dest = to_delete_key (hash, csum) in
|
let dest = to_delete_key (hash, csum) in
|
||||||
(* if the checksums mismatch we need to mark the file for deletion *)
|
Logs.warn (fun m -> m "Failed to remove %a: %a. Moving it to %a"
|
||||||
|
Mirage_kv.Key.pp source KV.pp_write_error e Mirage_kv.Key.pp dest);
|
||||||
KV.rename t.dev ~source ~dest >|= function
|
KV.rename t.dev ~source ~dest >|= function
|
||||||
| Ok () -> Error (`Bad_checksum (hash, csum))
|
| Ok () -> Error (`Bad_checksum (hash, csum))
|
||||||
| Error e ->
|
| Error e ->
|
||||||
|
|
Loading…
Reference in a new issue