From 6275a95cdb492e1852551448821b9ed965de1a37 Mon Sep 17 00:00:00 2001 From: Anuj Chaudhari Date: Thu, 8 Aug 2024 11:21:55 -0700 Subject: [PATCH] Fix file lock issue on windows (#204) --- config/clientconfignextgen_lock.go | 2 +- config/lock.go | 4 ++-- config/metadata_lock.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/clientconfignextgen_lock.go b/config/clientconfignextgen_lock.go index 2a173b4d..7afd4fcc 100644 --- a/config/clientconfignextgen_lock.go +++ b/config/clientconfignextgen_lock.go @@ -57,7 +57,7 @@ func ReleaseTanzuConfigNextGenLock() { if cfgNextGenLock == nil { return } - if errUnlock := cfgNextGenLock.Unlock(); errUnlock != nil { + if errUnlock := cfgNextGenLock.Close(); errUnlock != nil { panic(fmt.Sprintf("cannot release lock for tanzu config file, reason: %v", errUnlock)) } diff --git a/config/lock.go b/config/lock.go index 922bbfbe..84204c43 100644 --- a/config/lock.go +++ b/config/lock.go @@ -69,7 +69,7 @@ func ReleaseTanzuConfigLock() { if tanzuConfigLock == nil { return } - if errUnlock := tanzuConfigLock.Unlock(); errUnlock != nil { + if errUnlock := tanzuConfigLock.Close(); errUnlock != nil { panic(fmt.Sprintf("cannot release lock for tanzu config file, reason: %v", errUnlock)) } @@ -103,7 +103,7 @@ func getFileLockWithTimeOut(lockPath string, lockDuration time.Duration) (*filem select { case <-cancel: // Timed out, cleanup if necessary. - _ = flock.Unlock() + _ = flock.Close() case result <- err: } }() diff --git a/config/metadata_lock.go b/config/metadata_lock.go index 15309657..a13b8eed 100644 --- a/config/metadata_lock.go +++ b/config/metadata_lock.go @@ -57,7 +57,7 @@ func ReleaseTanzuMetadataLock() { if tanzuMetadataLock == nil { return } - if errUnlock := tanzuMetadataLock.Unlock(); errUnlock != nil { + if errUnlock := tanzuMetadataLock.Close(); errUnlock != nil { panic(fmt.Sprintf("cannot release lock for tanzu config metadata file, reason: %v", errUnlock)) }