Add directory parameter to Rmdir and Mkdir #100 #831

This will enable rclone to manage directories properly in the future.
This commit is contained in:
Nick Craig-Wood 2016-11-25 21:52:43 +00:00
parent c41b67ea08
commit aaa1370a36
34 changed files with 220 additions and 89 deletions

View file

@ -707,12 +707,12 @@ func ListDir(f Fs, w io.Writer) error {
}
// Mkdir makes a destination directory or container
func Mkdir(f Fs) error {
func Mkdir(f Fs, dir string) error {
if Config.DryRun {
Log(f, "Not making directory as dry run is set")
return nil
}
err := f.Mkdir()
err := f.Mkdir(dir)
if err != nil {
Stats.Error()
return err
@ -722,17 +722,17 @@ func Mkdir(f Fs) error {
// TryRmdir removes a container but not if not empty. It doesn't
// count errors but may return one.
func TryRmdir(f Fs) error {
func TryRmdir(f Fs, dir string) error {
if Config.DryRun {
Log(f, "Not deleting as dry run is set")
return nil
}
return f.Rmdir()
return f.Rmdir(dir)
}
// Rmdir removes a container but not if not empty
func Rmdir(f Fs) error {
err := TryRmdir(f)
func Rmdir(f Fs, dir string) error {
err := TryRmdir(f, dir)
if err != nil {
Stats.Error()
return err
@ -764,7 +764,7 @@ func Purge(f Fs) error {
if err != nil {
return err
}
err = Rmdir(f)
err = Rmdir(f, "")
}
if err != nil {
Stats.Error()