Skip to content

Commit

Permalink
fix upload preconditions (#222)
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic authored and labkode committed Aug 29, 2019
1 parent 240edc1 commit d793a91
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/revad/svcs/httpsvcs/ocdavsvc/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (s *svc) doOptions(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Credentials", "true")
w.Header().Set("Access-Control-Allow-Methods", allow)
w.Header().Set("Access-Control-Allow-Headers", "Authorization, Content-Type, Depth, Ocs-Apirequest, If-None-Match, Destination")
w.Header().Set("Access-Control-Allow-Headers", "Authorization, Content-Type, Depth, Ocs-Apirequest, If-Match, If-None-Match, Destination")
w.Header().Set("Content-Type", "application/xml")
w.Header().Set("Allow", allow)
w.Header().Set("DAV", "1, 2")
Expand Down
14 changes: 7 additions & 7 deletions pkg/storage/fs/owncloud/owncloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -957,13 +957,13 @@ func (fs *ocFS) Upload(ctx context.Context, ref *storageproviderv0alphapb.Refere
return errors.Wrap(err, "ocFS: error writing to tmp file "+tmp.Name())
}

// TODO(jfd): copy attributes of existing file to tmp file?
if err := fs.copyMD(np, tmp.Name()); err != nil {
return errors.Wrap(err, "ocFS: error copying metadata from "+np+" to "+tmp.Name())
}

// create revision if destination exists
if _, err := os.Stat(np); err != nil {
// if destination exists
if _, err := os.Stat(np); err == nil {
// copy attributes of existing file to tmp file
if err := fs.copyMD(np, tmp.Name()); err != nil {
return errors.Wrap(err, "ocFS: error copying metadata from "+np+" to "+tmp.Name())
}
// create revision
if err := fs.archiveRevision(ctx, np); err != nil {
return err
}
Expand Down

0 comments on commit d793a91

Please sign in to comment.