Skip to content

Commit

Permalink
fix mtime if 0 size file uploaded
Browse files Browse the repository at this point in the history
  • Loading branch information
2403905 committed Jun 23, 2023
1 parent 919a958 commit 4c9b034
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .drone.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# The test runner source for API tests
APITESTS_COMMITID=2ea3b8c400688b14ef328786b3af445c2edbbe18
APITESTS_COMMITID=c8f8bc55e22597bc3d53b63b2f38f345b4814b07
APITESTS_BRANCH=master
APITESTS_REPO_GIT_URL=https://github.com/owncloud/ocis.git
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-mtime.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: fix mtime if 0 size file uploaded

Fix mtime if 0 size file uploaded

https://github.com/cs3org/reva/pull/4012
https://github.com/owncloud/ocis/issues/1248
14 changes: 14 additions & 0 deletions internal/http/services/owncloud/ocdav/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,20 @@ func (s *svc) handlePut(ctx context.Context, w http.ResponseWriter, r *http.Requ
w.WriteHeader(http.StatusInternalServerError)
return
}
if mtime := r.Header.Get(net.HeaderOCMtime); mtime != "" {
smRes, err := client.SetArbitraryMetadata(ctx, &provider.SetArbitraryMetadataRequest{
Ref: ref,
ArbitraryMetadata: &provider.ArbitraryMetadata{Metadata: map[string]string{"mtime": mtime}},
})
if err != nil {
log.Warn().Msgf("failed to add the mtime %s, %s", mtime, err.Error())
}
if smRes.Status.Code != rpc.Code_CODE_OK {
log.Warn().Interface("status", smRes.Status).Msgf("failed to add the mtime %s, %s", mtime, smRes.Status.Message)
} else {
w.Header().Set(net.HeaderOCMtime, "accepted")
}
}
sRes, err := client.Stat(ctx, &provider.StatRequest{
Ref: ref,
})
Expand Down

0 comments on commit 4c9b034

Please sign in to comment.