Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix #285

Do not get stuck in a broken state: we always try to fix the lock errors, it's better to be a bit unsafe but not stuck.
  • Loading branch information...
commit 6e86353faf4ccd80024f44e0baa74954592048f2 1 parent a077ed7
Thomas Gazagnaire samoht authored
Showing with 14 additions and 9 deletions.
  1. +14 −9 src/core/opamSystem.ml
23 src/core/opamSystem.ml
View
@@ -391,17 +391,22 @@ let flock file =
let funlock file =
let id = string_of_int (Unix.getpid ()) in
- if Sys.file_exists file then begin
+ if Sys.file_exists file then (
let ic = open_in file in
- let s = input_line ic in
- close_in ic;
- if s = id then begin
- OpamGlobals.log id "unlocking %s" file;
+ try
+ let s = input_line ic in
+ close_in ic;
+ if s = id then (
+ OpamGlobals.log id "unlocking %s" file;
+ Unix.unlink file;
+ ) else
+ OpamGlobals.error_and_exit "cannot unlock %s (%s)" file s
+ with _ ->
+ OpamGlobals.error "%s is broken, removing it and continuing anyway ..." file;
+ close_in ic;
Unix.unlink file;
- end else
- OpamGlobals.error_and_exit "cannot unlock %s (%s)" file s
- end else if Sys.file_exists (Filename.basename file) then
- OpamGlobals.error_and_exit "Cannot find %s" file
+ ) else
+ OpamGlobals.error "Cannot find %s, but continuing anyway..." file
let ocaml_version = lazy (
try
Please sign in to comment.
Something went wrong with that request. Please try again.