diff --git a/src/internal/connector/onedrive/item.go b/src/internal/connector/onedrive/item.go index 4cf8a91f7..f76e989f2 100644 --- a/src/internal/connector/onedrive/item.go +++ b/src/internal/connector/onedrive/item.go @@ -96,10 +96,10 @@ type itemWriter struct { } const ( - contentRangeHeaderKey = "Content-Range" - contentLengthHeaderKey = "Content-Length" - // Format for Content-Length is "bytes -/" - contentLengthHeaderValueFmt = "bytes %d-%d/%d" + contentRangeHeaderKey = "Content-Range" + // Format for Content-Range is "bytes -/" + contentRangeHeaderValueFmt = "bytes %d-%d/%d" + contentLengthHeaderKey = "Content-Length" ) // Write will upload the provided data to OneDrive. It sets the `Content-Length` and `Content-Range` headers based on @@ -117,7 +117,7 @@ func (iw *itemWriter) Write(p []byte) (n int, err error) { // data in the current request resp, err := client.R(). SetHeaders(map[string]string{ - contentRangeHeaderKey: fmt.Sprintf(contentLengthHeaderValueFmt, + contentRangeHeaderKey: fmt.Sprintf(contentRangeHeaderValueFmt, iw.lastWrittenOffset, endOffset-1, iw.contentLength), diff --git a/src/internal/connector/onedrive/restore.go b/src/internal/connector/onedrive/restore.go index 0a06abeb5..d514a0aa6 100644 --- a/src/internal/connector/onedrive/restore.go +++ b/src/internal/connector/onedrive/restore.go @@ -136,7 +136,7 @@ func createRestoreFolders(ctx context.Context, service graph.Service, driveID st continue } - if err != errFolderNotFound { + if !errors.Is(err, errFolderNotFound) { return "", errors.Wrapf(err, "folder %s not found in drive(%s) parentFolder(%s)", folder, driveID, parentFolderID) } diff --git a/src/internal/connector/support/status.go b/src/internal/connector/support/status.go index 095d79851..3d691a4d7 100644 --- a/src/internal/connector/support/status.go +++ b/src/internal/connector/support/status.go @@ -56,7 +56,8 @@ func CreateStatus( "status object count does not match errors + successes", "objects", objects, "successes", success, - "errors", numErr) + "numErrors", numErr, + "errors", err.Error()) } return &status diff --git a/src/internal/kopia/wrapper.go b/src/internal/kopia/wrapper.go index 76fcb46cf..7bfec71fd 100644 --- a/src/internal/kopia/wrapper.go +++ b/src/internal/kopia/wrapper.go @@ -535,6 +535,7 @@ func getItemStream( return &kopiaDataStream{ uuid: decodedName, reader: r, + size: f.Size(), }, nil } diff --git a/src/internal/kopia/wrapper_test.go b/src/internal/kopia/wrapper_test.go index 42fdc0b99..89e3dd4a5 100644 --- a/src/internal/kopia/wrapper_test.go +++ b/src/internal/kopia/wrapper_test.go @@ -72,6 +72,10 @@ func testForFiles( require.NoError(t, err, "reading collection item: %s", fullPath) assert.Equal(t, expected, buf, "comparing collection item: %s", fullPath) + + require.Implements(t, (*data.StreamSize)(nil), s) + ss := s.(data.StreamSize) + assert.Equal(t, len(buf), int(ss.Size())) } }