Skip to content

Commit

Permalink
fix webdav copy for zero byte files (#2374)
Browse files Browse the repository at this point in the history
  • Loading branch information
wkloucek authored Dec 15, 2021
1 parent e65efdc commit 5cde018
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 28 deletions.
9 changes: 9 additions & 0 deletions changelog/unreleased/fix-webdav-copy-zero-byte-file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Bugfix: Fix webdav copy of zero byte files

We've fixed the webdav copy action of zero byte files, which was not performed
because the webdav api assumed, that zero byte uploads are created when initiating
the upload, which was recently removed from all storage drivers. Therefore the
webdav api also uploads zero byte files after initiating the upload.

https://github.com/cs3org/reva/pull/2374
https://github.com/cs3org/reva/pull/2309
53 changes: 25 additions & 28 deletions internal/http/services/owncloud/ocdav/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,22 +237,21 @@ func (s *svc) executePathCopy(ctx context.Context, client gateway.GatewayAPIClie

// 4. do upload

if cp.sourceInfo.GetSize() > 0 {
httpUploadReq, err := rhttp.NewRequest(ctx, "PUT", uploadEP, httpDownloadRes.Body)
if err != nil {
return err
}
httpUploadReq.Header.Set(datagateway.TokenTransportHeader, uploadToken)
httpUploadReq, err := rhttp.NewRequest(ctx, "PUT", uploadEP, httpDownloadRes.Body)
if err != nil {
return err
}
httpUploadReq.Header.Set(datagateway.TokenTransportHeader, uploadToken)

httpUploadRes, err := s.client.Do(httpUploadReq)
if err != nil {
return err
}
defer httpUploadRes.Body.Close()
if httpUploadRes.StatusCode != http.StatusOK {
return err
}
httpUploadRes, err := s.client.Do(httpUploadReq)
if err != nil {
return err
}
defer httpUploadRes.Body.Close()
if httpUploadRes.StatusCode != http.StatusOK {
return err
}

}
return nil
}
Expand Down Expand Up @@ -457,21 +456,19 @@ func (s *svc) executeSpacesCopy(ctx context.Context, w http.ResponseWriter, clie

// 4. do upload

if cp.sourceInfo.GetSize() > 0 {
httpUploadReq, err := rhttp.NewRequest(ctx, http.MethodPut, uploadEP, httpDownloadRes.Body)
if err != nil {
return err
}
httpUploadReq.Header.Set(datagateway.TokenTransportHeader, uploadToken)
httpUploadReq, err := rhttp.NewRequest(ctx, http.MethodPut, uploadEP, httpDownloadRes.Body)
if err != nil {
return err
}
httpUploadReq.Header.Set(datagateway.TokenTransportHeader, uploadToken)

httpUploadRes, err := s.client.Do(httpUploadReq)
if err != nil {
return err
}
defer httpUploadRes.Body.Close()
if httpUploadRes.StatusCode != http.StatusOK {
return err
}
httpUploadRes, err := s.client.Do(httpUploadReq)
if err != nil {
return err
}
defer httpUploadRes.Body.Close()
if httpUploadRes.StatusCode != http.StatusOK {
return err
}
}
return nil
Expand Down

0 comments on commit 5cde018

Please sign in to comment.