From a35f6c27bec550de4a40a92a8f71f7e75b14cdc7 Mon Sep 17 00:00:00 2001 From: Fabian Peters Date: Mon, 16 Mar 2020 15:56:31 +0100 Subject: [PATCH] Fix "Failed to upload the chunk ... sync ...: operation not supported" issue when using SMB on MacOS. This is done by inspecting the error type and returning the error only if its operation is "sync" and the type is "operation not supported". Note: this change is my first ever foray into go and based simply on the information provided in: https://forum.duplicacy.com/t/failed-to-upload-the-chunk-operation-not-supported/2875/11 --- src/duplicacy_filestorage.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/duplicacy_filestorage.go b/src/duplicacy_filestorage.go index 888c61d..604cffa 100644 --- a/src/duplicacy_filestorage.go +++ b/src/duplicacy_filestorage.go @@ -12,6 +12,7 @@ import ( "os" "path" "strings" + "syscall" "time" ) @@ -190,10 +191,13 @@ func (storage *FileStorage) UploadFile(threadIndex int, filePath string, content return err } - err = file.Sync() - if err != nil { - file.Close() - return err + if err = file.Sync(); err != nil { + pathErr, ok := err.(*os.PathError) + isNotSupported := ok && pathErr.Op == "sync" && pathErr.Err == syscall.ENOTSUP + if !isNotSupported { + _ = file.Close() + return err + } } err = file.Close()