dbuenzli / bos

Basic OS interaction for OCaml
http://erratique.ch/software/bos
ISC License
63 stars 16 forks source link

Bos.OS.Path.symlink ~force:true does not unlink reliably #75

Closed avsm closed 6 years ago

avsm commented 6 years ago
# Bos.OS.Path.symlink ~force:true ~target:Fpath.(v "foo") Fpath.(v "bar") ;;
- : (unit, _[> Rresult.R.msg ]) result = Result.Ok ()
# Bos.OS.Path.symlink ~force:true ~target:Fpath.(v "foo") Fpath.(v "bar") ;;
- : (unit, _[> Rresult.R.msg ]) result =
Result.Error (`Msg "force symlink foo to bar: No such file or directory")
# Bos.OS.Path.symlink ~target:Fpath.(v "foo") Fpath.(v "bar") ;;
- : (unit, _[> Rresult.R.msg ]) result =
Result.Error (`Msg "symlink foo to bar: File exists")

Unlinking before the symlink call works reliably, but I think the force:true should save this call.

dbuenzli commented 6 years ago

Mmmh that's odd. Unless I miss something there seem to be some kind of POSIX behaviour divergence here. The second call should return EEXIST and as a far as I can tell this is handled by the code.

dbuenzli commented 6 years ago

The error is in force_remove, here this should be lstat.