"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
accounting: populate transfer snapshot with "what" value
Timothy Jacobs7edf8eb23353
diff --git a/fs/accounting/stats_groups.go b/fs/accounting/stats_groups.goindex f209d4e64..a89866c7e 100644--- a/fs/accounting/stats_groups.go+++ b/fs/accounting/stats_groups.go@@ -176,6 +176,7 @@ Returns the following values:"size": size of the file in bytes,"bytes": total transferred bytes for this file,"checked": if the transfer is only checked (skipped, deleted),+ "what": the purpose of the transfer (transferring, deleting, checking, importing, hashing, merging, listing, moving, renaming),"timestamp": integer representing millisecond unix epoch,"error": string description of the error (empty if successful),"jobid": id of the job that this transfer belongs todiff --git a/fs/accounting/transfer.go b/fs/accounting/transfer.goindex f2bc67761..fc79c5ca1 100644--- a/fs/accounting/transfer.go+++ b/fs/accounting/transfer.go@@ -17,6 +17,7 @@ type TransferSnapshot struct {Size int64 `json:"size"`Bytes int64 `json:"bytes"`Checked bool `json:"checked"`+ What string `json:"what"`StartedAt time.Time `json:"started_at"`CompletedAt time.Time `json:"completed_at,omitempty"`Error error `json:"-"`@@ -184,11 +185,18 @@ func (tr *Transfer) Snapshot() TransferSnapshot {if tr.acc != nil {b, s = tr.acc.progress()}++ what := tr.what+ if what == "" {+ what = "transferring"+ }+snapshot := TransferSnapshot{Name: tr.remote,- Checked: tr.checking,Size: s,Bytes: b,+ Checked: tr.checking,+ What: what,StartedAt: tr.startedAt,CompletedAt: tr.completedAt,Error: tr.err,diff --git a/fs/accounting/transfer_test.go b/fs/accounting/transfer_test.goindex ec5c11e78..2aaa3d2c9 100644--- a/fs/accounting/transfer_test.go+++ b/fs/accounting/transfer_test.go@@ -31,6 +31,7 @@ func TestTransfer(t *testing.T) {assert.Equal(t, int64(0), snap.Size)assert.Equal(t, int64(0), snap.Bytes)assert.Equal(t, false, snap.Checked)+ assert.Equal(t, "transferring", snap.What)assert.Equal(t, false, snap.StartedAt.IsZero())assert.Equal(t, true, snap.CompletedAt.IsZero())assert.Equal(t, nil, snap.Error)@@ -46,6 +47,7 @@ func TestTransfer(t *testing.T) {assert.Equal(t, int64(0), snap.Size)assert.Equal(t, int64(0), snap.Bytes)assert.Equal(t, false, snap.Checked)+ assert.Equal(t, "transferring", snap.What)assert.Equal(t, false, snap.StartedAt.IsZero())assert.Equal(t, false, snap.CompletedAt.IsZero())assert.Equal(t, true, errors.Is(snap.Error, io.EOF))@@ -63,4 +65,21 @@ func TestTransfer(t *testing.T) {"dstFs": "dstFs:dstFs",}, out)})++ t.Run("Snapshot checking transfer", func(t *testing.T) {+ ctr := newCheckingTransfer(s, o, "checking")+ snap := ctr.Snapshot()++ assert.Equal(t, "obj", snap.Name)+ assert.Equal(t, int64(0), snap.Size)+ assert.Equal(t, int64(0), snap.Bytes)+ assert.Equal(t, true, snap.Checked)+ assert.Equal(t, "checking", snap.What)+ assert.Equal(t, false, snap.StartedAt.IsZero())+ assert.Equal(t, true, snap.CompletedAt.IsZero())+ assert.Equal(t, nil, snap.Error)+ assert.Equal(t, "", snap.Group)+ assert.Equal(t, "", snap.SrcFs)+ assert.Equal(t, "", snap.DstFs)+ })}