Esempio n. 1
0
// TestMkdir tests Mkdir works
func TestMkdir(t *testing.T, remote fs.Fs) {
	err := fs.Mkdir(remote)
	if err != nil {
		t.Fatalf("Mkdir failed: %v", err)
	}
	CheckListing(t, remote, []Item{})
}
Esempio n. 2
0
func TestRmdirs(t *testing.T) {
	r := NewRun(t)
	defer r.Finalise()
	r.Mkdir(r.fremote)

	// Clean any directories that have crept in so far
	// FIXME make the Finalise method do this?
	require.NoError(t, fs.Rmdirs(r.fremote))

	// Make some files and dirs we expect to keep
	r.ForceMkdir(r.fremote)
	file1 := r.WriteObject("A1/B1/C1/one", "aaa", t1)
	file2 := r.WriteObject("A1/two", "bbb", t2)
	//..and dirs we expect to delete
	require.NoError(t, fs.Mkdir(r.fremote, "A2"))
	require.NoError(t, fs.Mkdir(r.fremote, "A1/B2"))
	require.NoError(t, fs.Mkdir(r.fremote, "A1/B2/C2"))
	require.NoError(t, fs.Mkdir(r.fremote, "A1/B1/C3"))
	require.NoError(t, fs.Mkdir(r.fremote, "A3"))
	require.NoError(t, fs.Mkdir(r.fremote, "A3/B3"))
	require.NoError(t, fs.Mkdir(r.fremote, "A3/B3/C4"))

	fstest.CheckListingWithPrecision(
		t,
		r.fremote,
		[]fstest.Item{
			file1, file2,
		},
		[]string{
			"A1",
			"A1/B1",
			"A1/B1/C1",
			"A2",
			"A1/B2",
			"A1/B2/C2",
			"A1/B1/C3",
			"A3",
			"A3/B3",
			"A3/B3/C4",
		},
		fs.Config.ModifyWindow,
	)

	require.NoError(t, fs.Rmdirs(r.fremote))

	fstest.CheckListingWithPrecision(
		t,
		r.fremote,
		[]fstest.Item{
			file1, file2,
		},
		[]string{
			"A1",
			"A1/B1",
			"A1/B1/C1",
		},
		fs.Config.ModifyWindow,
	)

}
Esempio n. 3
0
// TestFsMkdirRmdirSubdir tests making and removing a sub directory
func TestFsMkdirRmdirSubdir(t *testing.T) {
	skipIfNotOk(t)
	dir := "dir/subdir"
	err := fs.Mkdir(remote, dir)
	require.NoError(t, err)
	fstest.CheckListingWithPrecision(t, remote, []fstest.Item{}, []string{"dir", "dir/subdir"}, fs.Config.ModifyWindow)

	err = fs.Rmdir(remote, dir)
	require.NoError(t, err)
	fstest.CheckListingWithPrecision(t, remote, []fstest.Item{}, []string{"dir"}, fs.Config.ModifyWindow)

	err = fs.Rmdir(remote, "dir")
	require.NoError(t, err)
	fstest.CheckListingWithPrecision(t, remote, []fstest.Item{}, []string{}, fs.Config.ModifyWindow)
}
Esempio n. 4
0
// Check that if the local file doesn't exist when we copy it up,
// nothing happens to the remote file
func TestCopyAfterDelete(t *testing.T) {
	r := NewRun(t)
	defer r.Finalise()
	file1 := r.WriteObject("sub dir/hello world", "hello world", t1)
	fstest.CheckItems(t, r.flocal)
	fstest.CheckItems(t, r.fremote, file1)

	err := fs.Mkdir(r.flocal)
	require.NoError(t, err)

	err = fs.CopyDir(r.fremote, r.flocal)
	require.NoError(t, err)

	fstest.CheckItems(t, r.flocal)
	fstest.CheckItems(t, r.fremote, file1)
}
Esempio n. 5
0
		Help: `
        Produces an md5sum file for all the objects in the path.  This
        is in the same format as the standard md5sum tool produces.`,
		Run: func(fdst, fsrc fs.Fs) error {
			return fs.Md5sum(fdst, os.Stdout)
		},
		MinArgs: 1,
		MaxArgs: 1,
	},
	{
		Name:     "mkdir",
		ArgsHelp: "remote:path",
		Help: `
        Make the path if it doesn't already exist`,
		Run: func(fdst, fsrc fs.Fs) error {
			return fs.Mkdir(fdst)
		},
		MinArgs: 1,
		MaxArgs: 1,
		Retry:   true,
	},
	{
		Name:     "rmdir",
		ArgsHelp: "remote:path",
		Help: `
        Remove the path.  Note that you can't remove a path with
        objects in it, use purge for that.`,
		Run: func(fdst, fsrc fs.Fs) error {
			return fs.Rmdir(fdst)
		},
		MinArgs: 1,
Esempio n. 6
0
// TestMkdir tests Mkdir works
func TestMkdir(t *testing.T, remote fs.Fs) {
	err := fs.Mkdir(remote)
	require.NoError(t, err)
	CheckListing(t, remote, []Item{})
}
Esempio n. 7
0
		Run: func(fdst, fsrc fs.Fs) {
			err := fs.Md5sum(fdst, os.Stdout)
			if err != nil {
				log.Fatalf("Failed to list: %v", err)
			}
		},
		MinArgs: 1,
		MaxArgs: 1,
	},
	{
		Name:     "mkdir",
		ArgsHelp: "remote:path",
		Help: `
        Make the path if it doesn't already exist`,
		Run: func(fdst, fsrc fs.Fs) {
			err := fs.Mkdir(fdst)
			if err != nil {
				log.Fatalf("Failed to mkdir: %v", err)
			}
		},
		MinArgs: 1,
		MaxArgs: 1,
	},
	{
		Name:     "rmdir",
		ArgsHelp: "remote:path",
		Help: `
        Remove the path.  Note that you can't remove a path with
        objects in it, use purge for that.`,
		Run: func(fdst, fsrc fs.Fs) {
			err := fs.Rmdir(fdst)
Esempio n. 8
0
File: mkdir.go Progetto: ncw/rclone
package mkdir

import (
	"github.com/ncw/rclone/cmd"
	"github.com/ncw/rclone/fs"
	"github.com/spf13/cobra"
)

func init() {
	cmd.Root.AddCommand(commandDefintion)
}

var commandDefintion = &cobra.Command{
	Use:   "mkdir remote:path",
	Short: `Make the path if it doesn't already exist.`,
	Run: func(command *cobra.Command, args []string) {
		cmd.CheckArgs(1, 1, command, args)
		fdst := cmd.NewFsDst(args)
		cmd.Run(true, false, command, func() error {
			return fs.Mkdir(fdst, "")
		})
	},
}