diff --git a/common/config.go b/common/config.go index 3eb61c4..6006be4 100644 --- a/common/config.go +++ b/common/config.go @@ -104,7 +104,7 @@ func NewConfigForIntegrationTests() *Config { DestructiveIntegrationTest: true, EmptyTrashAfterIntegrationTest: true, ReplaceExistingDraft: false, - DisableCaching: false, + DisableCaching: true, DataFolderName: "data", } diff --git a/file.go b/file.go index 81d4417..a6052ad 100644 --- a/file.go +++ b/file.go @@ -170,25 +170,25 @@ func (protonDrive *ProtonDrive) DownloadFile(ctx context.Context, link *proton.L return buffer.Bytes(), nil, nil } -func (protonDrive *ProtonDrive) UploadFileByReader(ctx context.Context, parentLinkID string, filename string, modTime time.Time, file io.Reader, testParam int) (*proton.Link, int64, error) { +func (protonDrive *ProtonDrive) UploadFileByReader(ctx context.Context, parentLinkID string, filename string, modTime time.Time, file io.Reader, testParam int) (string, int64, error) { parentLink, err := protonDrive.getLink(ctx, parentLinkID) if err != nil { - return nil, 0, err + return "", 0, err } return protonDrive.uploadFile(ctx, parentLink, filename, modTime, file, testParam) } -func (protonDrive *ProtonDrive) UploadFileByPath(ctx context.Context, parentLink *proton.Link, filename string, filePath string, testParam int) (*proton.Link, int64, error) { +func (protonDrive *ProtonDrive) UploadFileByPath(ctx context.Context, parentLink *proton.Link, filename string, filePath string, testParam int) (string, int64, error) { f, err := os.Open(filePath) if err != nil { - return nil, 0, err + return "", 0, err } defer f.Close() info, err := os.Stat(filePath) if err != nil { - return nil, 0, err + return "", 0, err } in := bufio.NewReader(f) @@ -540,7 +540,7 @@ func (protonDrive *ProtonDrive) commitNewRevision(ctx context.Context, nodeKR *c // 0 = normal mode // 1 = up to create revision // 2 = up to block upload -func (protonDrive *ProtonDrive) uploadFile(ctx context.Context, parentLink *proton.Link, filename string, modTime time.Time, file io.Reader, testParam int) (*proton.Link, int64, error) { +func (protonDrive *ProtonDrive) uploadFile(ctx context.Context, parentLink *proton.Link, filename string, modTime time.Time, file io.Reader, testParam int) (string, int64, error) { // TODO: if we should use github.com/gabriel-vasile/mimetype to detect the MIME type from the file content itself // Note: this approach might cause the upload progress to display the "fake" progress, since we read in all the content all-at-once // mimetype.SetLimit(0) @@ -557,46 +557,32 @@ func (protonDrive *ProtonDrive) uploadFile(ctx context.Context, parentLink *prot /* step 1: create a draft */ linkID, revisionID, newSessionKey, newNodeKR, err := protonDrive.createFileUploadDraft(ctx, parentLink, filename, modTime, mimeType) if err != nil { - return nil, 0, err + return "", 0, err } if testParam == 1 { - // for integration tests - // we try to simulate only draft is created but no upload is performed yet - finalLink, err := protonDrive.getLink(ctx, linkID) - if err != nil { - return nil, 0, err - } - return finalLink, 0, nil + return "", 0, nil } /* step 2: upload blocks and collect block data */ manifestSignature, fileSize, err := protonDrive.uploadAndCollectBlockData(ctx, newSessionKey, newNodeKR, file, linkID, revisionID) if err != nil { - return nil, 0, err + return "", 0, err } if testParam == 2 { // for integration tests // we try to simulate blocks uploaded but not yet commited - finalLink, err := protonDrive.getLink(ctx, linkID) - if err != nil { - return nil, 0, err - } - return finalLink, 0, nil + return "", 0, nil } /* step 3: mark the file as active by commiting the revision */ err = protonDrive.commitNewRevision(ctx, newNodeKR, modTime, fileSize, manifestSignature, linkID, revisionID) if err != nil { - return nil, 0, err + return "", 0, err } - finalLink, err := protonDrive.getLink(ctx, linkID) - if err != nil { - return nil, 0, err - } - return finalLink, fileSize, nil + return linkID, fileSize, nil } /* diff --git a/go.sum b/go.sum index 350d96d..caae598 100644 --- a/go.sum +++ b/go.sum @@ -49,8 +49,6 @@ github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSM github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/henrybear327/go-proton-api v0.0.0-20230713200642-3b697f4742b7 h1:OkRwTLGmzs9oMzQC0tmnCbRN32QJI43RXdUua0uCQYQ= -github.com/henrybear327/go-proton-api v0.0.0-20230713200642-3b697f4742b7/go.mod h1:l42xBSOrCmkAxzWUHcoUsG/cP8m1hMhV72GoChOX3bg= github.com/henrybear327/go-proton-api v0.0.0-20230713211354-02be61689e29 h1:OUVzxoIPZ6T4yC5hzvvIEjRaYwom3c9N5VwJgJvr9cs= github.com/henrybear327/go-proton-api v0.0.0-20230713211354-02be61689e29/go.mod h1:l42xBSOrCmkAxzWUHcoUsG/cP8m1hMhV72GoChOX3bg= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=