1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-06 00:03:32 +00:00

drime: rmdir, modtime, encoding, duplicates fixes

This commit is contained in:
dougal
2025-12-05 16:30:17 +00:00
parent fa4b299c3d
commit da45a5a5e5
2 changed files with 25 additions and 6 deletions

View File

@@ -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

View File

@@ -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