fix: build plugins/common on windows

On windows, `LockDirectory` now takes a `LockFileEx` lock on a `.dokku.lock` file inside the directory, as `flock` is unavailable there.
This commit is contained in:
Jose Diaz-Gonzalez committed 2026-11-08 21:13:25 -05:00
1 parent 12c1bf3493
commit 06a6fffb59
5 files changed
+91 -20

No files matched your search

+22
View File
@@ -7,6 +7,7 @@ import (
"path/filepath"
"strconv"
"sync"
"sync/atomic"
"testing"
"time"
@@ -269,6 +270,27 @@ func TestPropertyLockSerializesReadModifyWrite(t *testing.T) {
Expect(PropertyGet(propertyTestPlugin, propertyTestApp, "counter")).To(Equal("50"))
}
func TestLockDirectorySerializesConcurrentCallers(t *testing.T) {
RegisterTestingT(t)
t.Setenv(LockedDirectoriesEnvVar, "")
dir := t.TempDir()
var active atomic.Int32
var overlapped atomic.Bool
Expect(runConcurrently(20, func(i int) error {
return LockDirectory(dir, func() error {
if active.Add(1) > 1 {
overlapped.Store(true)
}
defer active.Add(-1)
time.Sleep(5 * time.Millisecond)
return nil
})
})).To(Succeed())
Expect(overlapped.Load()).To(BeFalse())
}
func TestLockDirectorySkipsDirectoriesHeldByParent(t *testing.T) {
setupPropertyMapTest(t)