Lock package directories with lock-files (fixes #957) #1116
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Synopsis
This pull request fixes #957 using a very simple lock-file approach where the presence of a special
.fpm-package-lock
indicates that anfpm
process is currently working on the package directory and that subsequentfpm
processes should wait for the lock-file to be removed.Checklist
Issues
fpm
right now)character(:), allocatable
,character(len=1), pointer
andtype(c_ptr)
are..Implementation notes
The mere presence of
.fpm-package-lock
is enough for indicate a lock. This means that there are scenarios where a lock-file exists but there is no way of telling if the process that created it is still going or if it crashed. For this reason, if anfpm
process sees that a lock-file exists already it prints an informative message to the user instructing them how to manually remove the lock if need be. (this is howgit
does it)I went down the path of implementing a more "sophisticated" locking mechanism (see the https://github.com/emmabastas/fpm/tree/concurrent-invocations for my struggles x)) but I ended up concluding that it wouldn't be worth implementing. here's what I wrote in a comment in
src/fpm_lock.f90
about that: