mirror of
https://github.com/rclone/rclone.git
synced 2026-10-10 06:55:45 -04:00
drime: fix deleted files and directories still being listed with hard_delete
With hard_delete set, deleted files and directories carried on being listed for about a second afterwards because the Drime server doesn't invalidate its cache of the parent folder listing when entries are deleted forever. This made removing a directory straight after emptying it fail with "directory not empty". Moving an entry to the trash does invalidate the cache, so with hard_delete set rclone now moves the entry to the trash first and then deletes it forever.
This commit is contained in:
1 parent
eb10c48a17
commit
a2e2b73725
1 file changed
+15
-1
+15
-1
@@ -692,13 +692,27 @@ func (f *Fs) Mkdir(ctx context.Context, dir string) error {
|
||||
|
||||
// deleteObject removes an object by ID
|
||||
func (f *Fs) deleteObject(ctx context.Context, id string) error {
|
||||
if f.opt.HardDelete {
|
||||
// Deleting forever doesn't invalidate the server's cache of
|
||||
// the parent folder listing, so the entry keeps being listed
|
||||
// for about a second. Moving to the trash first does.
|
||||
err := f.deleteEntry(ctx, id, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return f.deleteEntry(ctx, id, f.opt.HardDelete)
|
||||
}
|
||||
|
||||
// deleteEntry moves the entry with ID to the trash or deletes it forever
|
||||
func (f *Fs) deleteEntry(ctx context.Context, id string, deleteForever bool) error {
|
||||
opts := rest.Opts{
|
||||
Method: "POST",
|
||||
Path: "/file-entries/delete",
|
||||
}
|
||||
request := api.DeleteRequest{
|
||||
EntryIDs: []string{id},
|
||||
DeleteForever: f.opt.HardDelete,
|
||||
DeleteForever: deleteForever,
|
||||
}
|
||||
var result api.DeleteResponse
|
||||
err := f.pacer.Call(func() (bool, error) {
|
||||
|
||||
Reference in new issue
Block a user