Skip to content

Commit

Permalink
Merge pull request #1391 from alexlarsson/lockfiles-handle-partial-reads
Browse files Browse the repository at this point in the history
Correctly handle lockfiles without writes
  • Loading branch information
rhatdan authored Oct 17, 2022
2 parents ebf857f + ddb5de3 commit 54663e7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/lockfile/lockfile_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,10 @@ func (l *lockfile) Modified() (bool, error) {
if err != nil {
return true, err
}
if n != len(l.lw) {
return true, nil
}
// It is important to handle the partial read case, because
// the initial size of the lock file is zero, which is a valid
// state (no writes yet)
currentLW = currentLW[:n]
oldLW := l.lw
l.lw = currentLW
return !bytes.Equal(currentLW, oldLW), nil
Expand Down

0 comments on commit 54663e7

Please sign in to comment.