Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 1 changed file with 14 additions and 9 deletions. Show diff stats Hide diff stats

  1. +14 9 src/core/opamSystem.ml
23 src/core/opamSystem.ml
@@ -391,17 +391,22 @@ let flock file =
391 391
392 392 let funlock file =
393 393 let id = string_of_int (Unix.getpid ()) in
394   - if Sys.file_exists file then begin
  394 + if Sys.file_exists file then (
395 395 let ic = open_in file in
396   - let s = input_line ic in
397   - close_in ic;
398   - if s = id then begin
399   - OpamGlobals.log id "unlocking %s" file;
  396 + try
  397 + let s = input_line ic in
  398 + close_in ic;
  399 + if s = id then (
  400 + OpamGlobals.log id "unlocking %s" file;
  401 + Unix.unlink file;
  402 + ) else
  403 + OpamGlobals.error_and_exit "cannot unlock %s (%s)" file s
  404 + with _ ->
  405 + OpamGlobals.error "%s is broken, removing it and continuing anyway ..." file;
  406 + close_in ic;
400 407 Unix.unlink file;
401   - end else
402   - OpamGlobals.error_and_exit "cannot unlock %s (%s)" file s
403   - end else if Sys.file_exists (Filename.basename file) then
404   - OpamGlobals.error_and_exit "Cannot find %s" file
  408 + ) else
  409 + OpamGlobals.error "Cannot find %s, but continuing anyway..." file
405 410
406 411 let ocaml_version = lazy (
407 412 try

0 comments on commit 6e86353

Please sign in to comment.
Something went wrong with that request. Please try again.