当前位置: 首页>>代码示例>>Golang>>正文


Golang Fs.List方法代码示例

本文整理汇总了Golang中github.com/ncw/rclone/fs.Fs.List方法的典型用法代码示例。如果您正苦于以下问题:Golang Fs.List方法的具体用法?Golang Fs.List怎么用?Golang Fs.List使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/ncw/rclone/fs.Fs的用法示例。


在下文中一共展示了Fs.List方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: CheckListingWithPrecision

// CheckListingWithPrecision checks the fs to see if it has the
// expected contents with the given precision.
func CheckListingWithPrecision(t *testing.T, f fs.Fs, items []Item, precision time.Duration) {
	is := NewItems(items)
	oldErrors := fs.Stats.GetErrors()
	var objs []fs.Object
	for i := 1; i <= 5; i++ {
		objs = nil
		for obj := range f.List() {
			objs = append(objs, obj)
		}
		if len(objs) == len(items) {
			break
		}
		t.Logf("Sleeping for 1 second for list eventual consistency: %d/5", i)
		time.Sleep(1 * time.Second)
	}
	for _, obj := range objs {
		if obj == nil {
			t.Errorf("Unexpected nil in List()")
			continue
		}
		is.Find(t, obj, precision)
	}
	is.Done(t)
	// Don't notice an error when listing an empty directory
	if len(items) == 0 && oldErrors == 0 && fs.Stats.GetErrors() == 1 {
		fs.Stats.ResetErrors()
	}
}
开发者ID:nicot,项目名称:rclone,代码行数:30,代码来源:fstest.go

示例2: CheckListingWithPrecision

// Checks the fs to see if it has the expected contents
func CheckListingWithPrecision(t *testing.T, f fs.Fs, items []Item, precision time.Duration) {
	is := NewItems(items)
	for obj := range f.List() {
		if obj == nil {
			t.Errorf("Unexpected nil in List()")
			continue
		}
		is.Find(t, obj, precision)
	}
	is.Done(t)
}
开发者ID:shimondoodkin,项目名称:rclone,代码行数:12,代码来源:fstest.go

示例3: CheckListingWithPrecision

// Checks the fs to see if it has the expected contents
func CheckListingWithPrecision(t *testing.T, f fs.Fs, items []Item, precision time.Duration) {
	is := NewItems(items)
	oldErrors := fs.Stats.GetErrors()
	for obj := range f.List() {
		if obj == nil {
			t.Errorf("Unexpected nil in List()")
			continue
		}
		is.Find(t, obj, precision)
	}
	is.Done(t)
	// Don't notice an error when listing an empty directory
	if len(items) == 0 && oldErrors == 0 && fs.Stats.GetErrors() == 1 {
		fs.Stats.ResetErrors()
	}
}
开发者ID:X1011,项目名称:rclone,代码行数:17,代码来源:fstest.go

示例4: CheckListingWithPrecision

// CheckListingWithPrecision checks the fs to see if it has the
// expected contents with the given precision.
func CheckListingWithPrecision(t *testing.T, f fs.Fs, items []Item, precision time.Duration) {
	is := NewItems(items)
	oldErrors := fs.Stats.GetErrors()
	var objs []fs.Object
	const retries = 6
	sleep := time.Second / 2
	for i := 1; i <= retries; i++ {
		objs = nil
		for obj := range f.List() {
			objs = append(objs, obj)
		}
		if len(objs) == len(items) {
			// Put an extra sleep in if we did any retries just to make sure it really
			// is consistent (here is looking at you Amazon Cloud Drive!)
			if i != 1 {
				extraSleep := 5*time.Second + sleep
				t.Logf("Sleeping for %v just to make sure", extraSleep)
				time.Sleep(extraSleep)
			}
			break
		}
		sleep *= 2
		t.Logf("Sleeping for %v for list eventual consistency: %d/%d", sleep, i, retries)
		time.Sleep(sleep)
	}
	for _, obj := range objs {
		if obj == nil {
			t.Errorf("Unexpected nil in List()")
			continue
		}
		is.Find(t, obj, precision)
	}
	is.Done(t)
	// Don't notice an error when listing an empty directory
	if len(items) == 0 && oldErrors == 0 && fs.Stats.GetErrors() == 1 {
		fs.Stats.ResetErrors()
	}
}
开发者ID:greendayo7,项目名称:rclone,代码行数:40,代码来源:fstest.go


注:本文中的github.com/ncw/rclone/fs.Fs.List方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。