mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 16:34:30 +01:00
Make fallback purge delete empty directories too.
This was implemented to make the SFTP unit tests pass.
This commit is contained in:
parent
609671aabc
commit
288302c2cf
@ -25,7 +25,7 @@ empty directories in.
|
|||||||
cmd.CheckArgs(1, 1, command, args)
|
cmd.CheckArgs(1, 1, command, args)
|
||||||
fdst := cmd.NewFsDst(args)
|
fdst := cmd.NewFsDst(args)
|
||||||
cmd.Run(true, false, command, func() error {
|
cmd.Run(true, false, command, func() error {
|
||||||
return fs.Rmdirs(fdst)
|
return fs.Rmdirs(fdst, "")
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -877,8 +877,6 @@ func Rmdir(f Fs, dir string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Purge removes a container and all of its contents
|
// Purge removes a container and all of its contents
|
||||||
//
|
|
||||||
// FIXME doesn't delete local directories
|
|
||||||
func Purge(f Fs) error {
|
func Purge(f Fs) error {
|
||||||
doFallbackPurge := true
|
doFallbackPurge := true
|
||||||
var err error
|
var err error
|
||||||
@ -900,7 +898,7 @@ func Purge(f Fs) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = Rmdir(f, "")
|
err = Rmdirs(f, "")
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Stats.Error()
|
Stats.Error()
|
||||||
@ -1207,8 +1205,8 @@ func Cat(f Fs, w io.Writer) error {
|
|||||||
|
|
||||||
// Rmdirs removes any empty directories (or directories only
|
// Rmdirs removes any empty directories (or directories only
|
||||||
// containing empty directories) under f, including f.
|
// containing empty directories) under f, including f.
|
||||||
func Rmdirs(f Fs) error {
|
func Rmdirs(f Fs, dir string) error {
|
||||||
list := NewLister().Start(f, "")
|
list := NewLister().Start(f, dir)
|
||||||
dirEmpty := make(map[string]bool)
|
dirEmpty := make(map[string]bool)
|
||||||
dirEmpty[""] = true
|
dirEmpty[""] = true
|
||||||
for {
|
for {
|
||||||
|
@ -672,7 +672,7 @@ func TestRmdirs(t *testing.T) {
|
|||||||
|
|
||||||
// Clean any directories that have crept in so far
|
// Clean any directories that have crept in so far
|
||||||
// FIXME make the Finalise method do this?
|
// FIXME make the Finalise method do this?
|
||||||
require.NoError(t, fs.Rmdirs(r.fremote))
|
require.NoError(t, fs.Rmdirs(r.fremote, ""))
|
||||||
|
|
||||||
// Make some files and dirs we expect to keep
|
// Make some files and dirs we expect to keep
|
||||||
r.ForceMkdir(r.fremote)
|
r.ForceMkdir(r.fremote)
|
||||||
@ -708,7 +708,7 @@ func TestRmdirs(t *testing.T) {
|
|||||||
fs.Config.ModifyWindow,
|
fs.Config.ModifyWindow,
|
||||||
)
|
)
|
||||||
|
|
||||||
require.NoError(t, fs.Rmdirs(r.fremote))
|
require.NoError(t, fs.Rmdirs(r.fremote, ""))
|
||||||
|
|
||||||
fstest.CheckListingWithPrecision(
|
fstest.CheckListingWithPrecision(
|
||||||
t,
|
t,
|
||||||
|
Loading…
Reference in New Issue
Block a user