From a2c69f2e679081fc6d2e9ff86974dc7a399ba00a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Grill?= Date: Sat, 26 Oct 2024 09:20:50 +0200 Subject: [PATCH] removed locks and fixed synchronization --- core/cfapi/filesystem/synclocaltoremote.go | 5 +---- core/cfapi/filesystem/syncremotetolocal.go | 2 -- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/core/cfapi/filesystem/synclocaltoremote.go b/core/cfapi/filesystem/synclocaltoremote.go index 2059cbe..32908e2 100644 --- a/core/cfapi/filesystem/synclocaltoremote.go +++ b/core/cfapi/filesystem/synclocaltoremote.go @@ -45,8 +45,6 @@ func (instance *VirtualizationInstance) isDeletedRemotely(remotepath string, loc } func (instance *VirtualizationInstance) syncLocalToRemote() error { - instance.lock.Lock() - defer instance.lock.Unlock() return filepath.Walk(instance.rootPath, func(localpath string, localinfo fs.FileInfo, err error) error { instance.Logger.Debug().Msgf("Syncing local file '%s'", localpath) if os.IsNotExist(err) { @@ -84,7 +82,7 @@ func (instance *VirtualizationInstance) syncLocalToRemote() error { remoteinfo, err := instance.fs.Stat(path) var localisnewer bool if os.IsNotExist(err) { - localisnewer = false + localisnewer = true } else if err != nil { return fmt.Errorf("syncLocalToRemote.1 %w", err) } else if remoteinfo == nil { @@ -107,7 +105,6 @@ func (instance *VirtualizationInstance) syncLocalToRemote() error { } // mark file as in-sync return instance.setInSync(localpath) - } if deleted { diff --git a/core/cfapi/filesystem/syncremotetolocal.go b/core/cfapi/filesystem/syncremotetolocal.go index 27978d3..8c02435 100644 --- a/core/cfapi/filesystem/syncremotetolocal.go +++ b/core/cfapi/filesystem/syncremotetolocal.go @@ -14,8 +14,6 @@ import ( ) func (instance *VirtualizationInstance) syncRemoteToLocal() error { - instance.lock.Lock() - defer instance.lock.Unlock() return utils.Walk(instance.fs, "", func(path string, remoteinfo fs.FileInfo, err error) error { instance.Logger.Debug().Msgf("Syncing remote file '%s'", path) if os.IsNotExist(err) {