How to purge directory when syncing?

Hi, I'm writing a backend, it supports deleting non-empty directories.
I want to purge directory instead of recursive deleting when syncing, but I haven't found such global option.
Can you tell me how to do?

The optional Purge method is for deleting a non-empty directory. Have you implemented that?

You use it withrclone purge remote:dir

Yes, I've implemented it, but I want to rclone to purge in sync, but not running purge manually.

That would be a nicer efficiency gain.

That would need a separate patch.

Also the interface to Purge would need to change to take a directory name (I've been meaning to do that for ages!)

Will modifying interface be difficult to adapt? If so, how about adding an interface and gradually adapting?

It needs every backend to be modified, so not easy but not too hard either.

That is a possibility also.

Another idea would be to add the dir parameter everywhere and also add some lines like this - rclone will use the Purge fallback if you return the Cant purge error.

func (f *Fs) Purge(ctx context.Context, dir string) error {
    if dir != "" {
        return fs.ErrorCantPurge
    }
    // ....
}

It's OK, but it's too hard for me to modify every backend...
I saw it in https://github.com/rclone/rclone/issues/1891

OK I'll modify all the backends... It won't take too long!

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.