diff --git a/backend/drime/api/types.go b/backend/drime/api/types.go index e1dc5904c..3d768537d 100644 --- a/backend/drime/api/types.go +++ b/backend/drime/api/types.go @@ -93,7 +93,7 @@ type CreateFolderRequest struct { type CreateFolderResponse struct { Status string `json:"status"` - Folder Item `json:"fileEntry"` + Folder Item `json:"folder"` } const ( @@ -267,7 +267,8 @@ type AccountsGet struct { // DeleteRequest is the input to DELETE /contents type DeleteRequest struct { - ContentsID string `json:"contentsId"` // comma separated list of IDs + EntryIds []string `json:"entryIds"` + DeleteForever bool `json:"deleteForever"` } // DeleteResponse is the input to DELETE /contents diff --git a/backend/drime/drime.go b/backend/drime/drime.go index bf7235f69..2ef75815b 100644 --- a/backend/drime/drime.go +++ b/backend/drime/drime.go @@ -98,6 +98,7 @@ Leave this blank normally, rclone will fill it in automatically. encoder.EncodeColon | encoder.EncodeLtGt | encoder.EncodeQuestion | + encoder.EncodeLeftSpace | encoder.EncodeBackSlash | encoder.EncodePipe | encoder.EncodeExclamation | @@ -793,11 +794,12 @@ func (f *Fs) DirSetModTime(ctx context.Context, dir string, modTime time.Time) e // deleteObject removes an object by ID func (f *Fs) deleteObject(ctx context.Context, id string) error { opts := rest.Opts{ - Method: "DELETE", - Path: "/contents/", + Method: "POST", + Path: "/file-entries/delete", } request := api.DeleteRequest{ - ContentsID: id, + EntryIds: []string{id}, + DeleteForever: false, // FIXME: hard delete? } var result api.DeleteResponse err := f.pacer.Call(func() (bool, error) { @@ -861,7 +863,7 @@ func (f *Fs) Rmdir(ctx context.Context, dir string) error { // Precision return the precision of this Fs func (f *Fs) Precision() time.Duration { - return time.Second + return fs.ModTimeNotSupported } // Purge deletes all the files and the container @@ -1404,6 +1406,22 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op return err } + // If the file exists, delete it after a successful upload + if o.id != "" { + id := o.id + o.id = "" + defer func() { + if err != nil { + return + } + fs.Debugf(o, "Removing old object on successful upload") + deleteErr := o.fs.deleteObject(ctx, id) + if deleteErr != nil { + err = fmt.Errorf("failed to delete existing object: %w", deleteErr) + } + }() + } + // Do the upload var resp *http.Response var result api.UploadResponse