Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Set up Go test for ${{ matrix.go-version }} on ${{ matrix.os }}
- name: Set up workflow for ${{ matrix.go-version }} on ${{ matrix.os }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
Expand Down
2 changes: 1 addition & 1 deletion dev.enc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5f990c89f9b5f406e2e6d3c641b6fea7efadd697e759f5b63f1cdfa6265f38d957eeb3==--==25a5bf6099052bf3b862e49f
27737e8dfe9f1835d42dbf06f0b0f609431c40bd951f496819d917a47a0b25b644fa78==--==a7630f58252bb75c65ccff8f
61 changes: 0 additions & 61 deletions filelock.go

This file was deleted.

24 changes: 0 additions & 24 deletions filelock_test.go

This file was deleted.

5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ module github.com/dsa0x/sicher

go 1.17

require golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
require (
github.com/juju/fslock v0.0.0-20160525022230-4d5c94c67b4b // indirect
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
github.com/juju/fslock v0.0.0-20160525022230-4d5c94c67b4b h1:FQ7+9fxhyp82ks9vAuyPzG0/vVbWwMwLJ+P6yJI5FN8=
github.com/juju/fslock v0.0.0-20160525022230-4d5c94c67b4b/go.mod h1:HMcgvsgd0Fjj4XXDkbjdmlbI505rUPBs6WBMYg2pXks=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
9 changes: 7 additions & 2 deletions sicher.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
"reflect"
"regexp"
"time"

"github.com/juju/fslock"
)

var delimiter = "==--=="
Expand Down Expand Up @@ -191,8 +193,11 @@ func (s *sicher) Edit(editor ...string) error {
defer credFile.Close()

// lock file to enable only one edit at a time
credFileLock := newFileLock(credFile)
credFileLock.LockWithTimeout(time.Second * 10)
credFileLock := fslock.New(credFile.Name()) //newFileLock(credFile)
err = credFileLock.LockWithTimeout(time.Second * 10)
if err != nil {
return fmt.Errorf("error locking file: %s", err)
}
defer credFileLock.Unlock()

var buf bytes.Buffer
Expand Down