"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
list: fix ext sort error sometimes being ignored at the end of a listing
Nick Craig-Wood7436d05e36d0
diff --git a/fs/list/sorter.go b/fs/list/sorter.goindex b9d759abe..e44bc7932 100644--- a/fs/list/sorter.go+++ b/fs/list/sorter.go@@ -305,6 +305,11 @@ func (ls *Sorter) Send() (err error) {}}}+ // The select may see outputChan closed before reading the+ // error the sorter sent on errChan+ if err := <-ls.errChan; err != nil {+ return err+ }err = list.Flush()if err != nil {return errdiff --git a/fs/list/sorter_test.go b/fs/list/sorter_test.goindex 2ba8d80bd..bdbe16c3b 100644--- a/fs/list/sorter_test.go+++ b/fs/list/sorter_test.go@@ -3,6 +3,7 @@ package listimport ("cmp""context"+ "errors""fmt""os""path/filepath"@@ -285,6 +286,31 @@ func TestSorterExtTempFileError(t *testing.T) {require.Error(t, err)}+// Test that Send returns the error from the ext sort when the ext+// sort closes its output and error channels before Send reads them.+func TestSorterExtSendError(t *testing.T) {+ ctx := context.Background()+ callback := func(entries fs.DirEntries) error {+ return nil+ }+ // select picks randomly between ready channels so try many times+ for range 100 {+ ls, err := NewSorter(ctx, nil, callback, nil)+ require.NoError(t, err)+ outputChan := make(chan string)+ close(outputChan)+ errChan := make(chan error, 1)+ errChan <- errors.New("sort failed")+ close(errChan)+ ls.extSort = true+ ls.inputChan = make(chan string)+ ls.outputChan = outputChan+ ls.errChan = errChan+ require.EqualError(t, ls.Send(), "sort failed")+ ls.CleanUp()+ }+}+// benchFs implements enough of the fs.Fs interface for Sortertype benchFs struct{}