Open mafredri opened 7 years ago
@rupa ping. Could you please review and merge this? I've been using it for two months and so far had no races and DB corruptions.
@rupa ping
@rupa ping
Yes please! Would love to see this get merged.
@rupa gentle ping
This would be very useful..
As this PR is coming up on two years, I'm closing it. If there's anything I can do to make it land, I'd be happy to fix. For example, if the use of mktemp
is a problem, it would not be needed if we also landed https://github.com/rupa/z/pull/247.
sorry my friend, I haven't have a lot of bandwidth, I don't use zsh, and I am definitely slow on changes with this project for a variety of reasons. This is an issue though, and i'd prefer it stay open.
Thanks, and apologies
@rupa that's quite alright, I understand 😄. Rebased on master to get rid of the conflicts.
This PR adds support for locking the database (via advisory file locking) during update when
zsh
is used as shell. This is done viazsystem flock
that is available in thezsh/system
module. The lock is acquired before the database is read and kept until the (new) database has been written and the command has exited.A separate code path is needed when updating the database entry because replacing the file (via mv) would cause any process waiting for a lock to fail. Here we simply clobber the database with the contents of the tempfile.
This is a partial fix for #198, more specifically, this only fixes the problem on
zsh
.// ping @balta2ar