當前位置: 首頁>>代碼示例>>Golang>>正文


Golang fs.CopyDir函數代碼示例

本文整理匯總了Golang中github.com/ncw/rclone/fs.CopyDir函數的典型用法代碼示例。如果您正苦於以下問題:Golang CopyDir函數的具體用法?Golang CopyDir怎麽用?Golang CopyDir使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了CopyDir函數的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestCopy

// Now without dry run
func TestCopy(t *testing.T) {
	r := NewRun(t)
	defer r.Finalise()
	file1 := r.WriteFile("sub dir/hello world", "hello world", t1)

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

	fstest.CheckItems(t, r.flocal, file1)
	fstest.CheckItems(t, r.fremote, file1)
}
開發者ID:marcopaganini,項目名稱:rclone,代碼行數:12,代碼來源:sync_test.go

示例2: TestCopyRedownload

// Check the copy downloading a file
func TestCopyRedownload(t *testing.T) {
	r := NewRun(t)
	defer r.Finalise()
	file1 := r.WriteObject("sub dir/hello world", "hello world", t1)
	fstest.CheckItems(t, r.fremote, file1)

	err := fs.CopyDir(r.flocal, r.fremote)
	if err != nil {
		t.Fatalf("Copy failed: %v", err)
	}

	fstest.CheckItems(t, r.flocal, file1)
}
開發者ID:vanphong3783,項目名稱:rclone,代碼行數:14,代碼來源:operations_test.go

示例3: TestCopy

// Now without dry run
func TestCopy(t *testing.T) {
	err := fs.CopyDir(fremote, flocal)
	if err != nil {
		t.Fatalf("Copy failed: %v", err)
	}

	items := []fstest.Item{
		{Path: "sub dir/hello world", Size: 11, ModTime: t1, Md5sum: "5eb63bbbe01eeed093cb22bb8f5acdc3"},
	}

	fstest.CheckListingWithPrecision(t, flocal, items, fs.Config.ModifyWindow)
	fstest.CheckListingWithPrecision(t, fremote, items, fs.Config.ModifyWindow)
}
開發者ID:vlinhd11,項目名稱:rclone,代碼行數:14,代碼來源:operations_test.go

示例4: TestCopyWithDryRun

// Check dry run is working
func TestCopyWithDryRun(t *testing.T) {
	r := NewRun(t)
	defer r.Finalise()
	file1 := r.WriteFile("sub dir/hello world", "hello world", t1)
	r.Mkdir(r.fremote)

	fs.Config.DryRun = true
	err := fs.CopyDir(r.fremote, r.flocal)
	fs.Config.DryRun = false
	require.NoError(t, err)

	fstest.CheckItems(t, r.flocal, file1)
	fstest.CheckItems(t, r.fremote)
}
開發者ID:ncw,項目名稱:rclone,代碼行數:15,代碼來源:sync_test.go

示例5: TestCopyWithDryRun

// Check dry run is working
func TestCopyWithDryRun(t *testing.T) {
	r := NewRun(t)
	defer r.Finalise()
	file1 := r.WriteFile("sub dir/hello world", "hello world", t1)

	fs.Config.DryRun = true
	err := fs.CopyDir(r.fremote, r.flocal)
	fs.Config.DryRun = false
	if err != nil {
		t.Fatalf("Copy failed: %v", err)
	}

	fstest.CheckItems(t, r.flocal, file1)
	fstest.CheckItems(t, r.fremote)
}
開發者ID:vanphong3783,項目名稱:rclone,代碼行數:16,代碼來源:operations_test.go

示例6: TestServerSideCopy

// Test a server side copy if possible, or the backup path if not
func TestServerSideCopy(t *testing.T) {
	r := NewRun(t)
	defer r.Finalise()
	file1 := r.WriteObject("sub dir/hello world", "hello world", t1)
	fstest.CheckItems(t, r.fremote, file1)

	fremoteCopy, _, finaliseCopy, err := fstest.RandomRemote(*RemoteName, *SubDir)
	require.NoError(t, err)
	defer finaliseCopy()
	t.Logf("Server side copy (if possible) %v -> %v", r.fremote, fremoteCopy)

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

	fstest.CheckItems(t, fremoteCopy, file1)
}
開發者ID:marcopaganini,項目名稱:rclone,代碼行數:17,代碼來源:sync_test.go

示例7: TestCopyWithDepth

// Test copy with depth
func TestCopyWithDepth(t *testing.T) {
	r := NewRun(t)
	defer r.Finalise()
	file1 := r.WriteFile("sub dir/hello world", "hello world", t1)
	file2 := r.WriteFile("hello world2", "hello world2", t2)

	// Check the MaxDepth too
	fs.Config.MaxDepth = 1
	defer func() { fs.Config.MaxDepth = -1 }()

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

	fstest.CheckItems(t, r.flocal, file1, file2)
	fstest.CheckItems(t, r.fremote, file2)
}
開發者ID:marcopaganini,項目名稱:rclone,代碼行數:17,代碼來源:sync_test.go

示例8: TestServerSideMove

// Test a server side move if possible, or the backup path if not
func TestServerSideMove(t *testing.T) {
	fremoteMove, finaliseMove, err := fstest.RandomRemote(*RemoteName, *SubDir)
	if err != nil {
		t.Fatalf("Failed to open remote move %q: %v", *RemoteName, err)
	}
	defer finaliseMove()
	t.Logf("Server side move (if possible) %v -> %v", fremote, fremoteMove)

	// Start with a copy
	err = fs.CopyDir(fremoteMove, fremote)
	if err != nil {
		t.Fatalf("Server Side Copy failed: %v", err)
	}

	// Remove one file
	obj := fremoteMove.NewFsObject("potato2")
	if obj == nil {
		t.Fatalf("Failed to find potato2")
	}
	err = obj.Remove()
	if err != nil {
		t.Fatalf("Failed to remove object: %v", err)
	}

	// Do server side move
	err = fs.MoveDir(fremoteMove, fremote)
	if err != nil {
		t.Fatalf("Server Side Move failed: %v", err)
	}

	items := []fstest.Item{
		{Path: "empty space", Size: 0, ModTime: t2, Md5sum: "d41d8cd98f00b204e9800998ecf8427e"},
		{Path: "potato2", Size: 60, ModTime: t1, Md5sum: "d6548b156ea68a4e003e786df99eee76"},
	}

	fstest.CheckListingWithPrecision(t, fremote, items[:0], fs.Config.ModifyWindow)
	fstest.CheckListingWithPrecision(t, fremoteMove, items, fs.Config.ModifyWindow)

	// Move it back again, dst does not exist this time
	err = fs.MoveDir(fremote, fremoteMove)
	if err != nil {
		t.Fatalf("Server Side Move 2 failed: %v", err)
	}

	fstest.CheckListingWithPrecision(t, fremote, items, fs.Config.ModifyWindow)
	fstest.CheckListingWithPrecision(t, fremoteMove, items[:0], fs.Config.ModifyWindow)
}
開發者ID:vlinhd11,項目名稱:rclone,代碼行數:48,代碼來源:operations_test.go

示例9: TestServerSideCopy

// Test a server side copy if possible, or the backup path if not
func TestServerSideCopy(t *testing.T) {
	r := NewRun(t)
	defer r.Finalise()
	file1 := r.WriteObject("sub dir/hello world", "hello world", t1)
	fstest.CheckItems(t, r.fremote, file1)

	fremoteCopy, finaliseCopy, err := fstest.RandomRemote(*RemoteName, *SubDir)
	if err != nil {
		t.Fatalf("Failed to open remote copy %q: %v", *RemoteName, err)
	}
	defer finaliseCopy()
	t.Logf("Server side copy (if possible) %v -> %v", r.fremote, fremoteCopy)

	err = fs.CopyDir(fremoteCopy, r.fremote)
	if err != nil {
		t.Fatalf("Server Side Copy failed: %v", err)
	}

	fstest.CheckItems(t, fremoteCopy, file1)
}
開發者ID:vanphong3783,項目名稱:rclone,代碼行數:21,代碼來源:operations_test.go

示例10: TestServerSideCopy

// Test a server side copy if possible, or the backup path if not
func TestServerSideCopy(t *testing.T) {
	fremoteCopy, finaliseCopy, err := fstest.RandomRemote(*RemoteName, *SubDir)
	if err != nil {
		t.Fatalf("Failed to open remote copy %q: %v", *RemoteName, err)
	}
	defer finaliseCopy()
	t.Logf("Server side copy (if possible) %v -> %v", fremote, fremoteCopy)

	err = fs.CopyDir(fremoteCopy, fremote)
	if err != nil {
		t.Fatalf("Server Side Copy failed: %v", err)
	}

	items := []fstest.Item{
		{Path: "sub dir/hello world", Size: 11, ModTime: t1, Md5sum: "5eb63bbbe01eeed093cb22bb8f5acdc3"},
	}

	fstest.CheckListingWithPrecision(t, fremote, items, fs.Config.ModifyWindow)
	fstest.CheckListingWithPrecision(t, fremoteCopy, items, fs.Config.ModifyWindow)
}
開發者ID:vlinhd11,項目名稱:rclone,代碼行數:21,代碼來源:operations_test.go

示例11:

		fmt.Fprintf(os.Stderr, "Command %s needs %d arguments maximum\n", cmd.Name, cmd.MaxArgs)
		os.Exit(1)
	}
}

// Commands is a slice of possible Command~s
var Commands = []Command{
	{
		Name:     "copy",
		ArgsHelp: "source:path dest:path",
		Help: `
        Copy the source to the destination.  Doesn't transfer
        unchanged files, testing by size and modification time or
        MD5SUM.  Doesn't delete files from the destination.`,
		Run: func(fdst, fsrc fs.Fs) error {
			return fs.CopyDir(fdst, fsrc)
		},
		MinArgs: 2,
		MaxArgs: 2,
		Retry:   true,
	},
	{
		Name:     "sync",
		ArgsHelp: "source:path dest:path",
		Help: `
        Sync the source to the destination, changing the destination
        only.  Doesn't transfer unchanged files, testing by size and
        modification time or MD5SUM.  Destination is updated to match
        source, including deleting files if necessary.  Since this can
        cause data loss, test first with the --dry-run flag.`,
		Run: func(fdst, fsrc fs.Fs) error {
開發者ID:JoeyGo23,項目名稱:rclone,代碼行數:31,代碼來源:rclone.go


注:本文中的github.com/ncw/rclone/fs.CopyDir函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。