本文整理汇总了Golang中github.com/akaspin/bar/client/lists.NewFileList函数的典型用法代码示例。如果您正苦于以下问题:Golang NewFileList函数的具体用法?Golang NewFileList怎么用?Golang NewFileList使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewFileList函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Test_Transport_Download_Many
func Test_Transport_Download_Many(t *testing.T) {
// t.Skip()
root := "Download-many"
halt, tree, ml, _, tr := seed(t, root)
defer halt()
assert.NoError(t, tree.PopulateN(10, 1000))
mx, err := ml.FeedManifests(true, true, true, lists.NewFileList().ListDir(tree.CWD)...)
assert.NoError(t, err)
err = tr.Upload(mx)
assert.NoError(t, err)
// Kill some blobs
tree.KillBLOB("file-two.bin")
tree.KillBLOB("one/file-two.bin")
tree.KillBLOB("one/file-three.bin")
req := lists.BlobMap{
"file-two.bin": mx["file-two.bin"],
"one/file-two.bin": mx["one/file-two.bin"],
"one/file-three.bin": mx["one/file-three.bin"],
}
for i := 0; i < 256; i++ {
nm := fmt.Sprintf("big/file-big-%d.bin", i)
tree.KillBLOB(nm)
req[nm] = mx[nm]
}
err = tr.Download(req)
assert.NoError(t, err)
}
示例2: Test_Transport_FetchSpec
func Test_Transport_FetchSpec(t *testing.T) {
// t.Skip()
root := "Spec"
halt, tree, ml, _, tr := seed(t, root)
defer halt()
mx, err := ml.FeedManifests(true, true, true, lists.NewFileList().ListDir(tree.CWD)...)
assert.NoError(t, err)
err = tr.Upload(mx)
assert.NoError(t, err)
// make spec
nameMap := map[string]proto.ID{}
for name, m := range mx {
nameMap[name] = m.ID
}
spec1, err := proto.NewSpec(time.Now().UnixNano(), nameMap, []string{})
assert.NoError(t, err)
err = tr.UploadSpec(spec1)
assert.NoError(t, err)
spec2, err := tr.GetSpec(spec1.ID)
assert.NoError(t, err)
assert.Equal(t, spec1.ID, spec2.ID)
}
示例3: Test_Assembler_Assemble
func Test_Assembler_Assemble(t *testing.T) {
tree := fixtures.NewTree("Assembler", "")
assert.NoError(t, tree.Populate())
defer tree.Squash()
ml, err := model.New(tree.CWD, false, proto.CHUNK_SIZE, 16)
assert.NoError(t, err)
names := []string{
"file-two.bin", "one/file-two.bin", "one/file-three.bin",
}
// get manifests
mx, err := ml.FeedManifests(true, true, true,
lists.NewFileList(names...).ListDir(tree.CWD)...)
assert.NoError(t, err)
a, err := model.NewAssembler(ml)
assert.NoError(t, err)
for name, man := range mx {
f, err := os.Open(filepath.Join(tree.CWD, name))
assert.NoError(t, err)
for _, chunk := range man.Chunks {
buf := make([]byte, chunk.Size)
_, err = f.Read(buf)
assert.NoError(t, err)
err = a.StoreChunk(bytes.NewReader(buf), chunk.ID)
assert.NoError(t, err)
}
}
// Kill some blobs
tree.KillBLOB("file-two.bin")
tree.KillBLOB("one/file-two.bin")
err = a.Done(mx)
assert.NoError(t, err)
mx1, err := ml.FeedManifests(true, true, true,
lists.NewFileList(names...).ListDir(tree.CWD)...)
assert.NoError(t, err)
assert.Equal(t, mx, mx1)
}
示例4: Test_Filelist1
func Test_Filelist1(t *testing.T) {
lister := lists.NewFileList()
assert.Equal(t, []string{"a", "b"}, lister.List([]string{
"a",
"b",
".hidden",
"deep/.hidden",
}))
}
示例5: Test_Transport_Upload
func Test_Transport_Upload(t *testing.T) {
root := "Upload"
halt, tree, ml, _, tr := seed(t, root)
defer halt()
mx, err := ml.FeedManifests(true, true, true, lists.NewFileList().ListDir(tree.CWD)...)
assert.NoError(t, err)
err = tr.Upload(mx)
assert.NoError(t, err)
}
示例6: Test_Model_IsBlobs
func Test_Model_IsBlobs(t *testing.T) {
tree := fixtures.NewTree("is-blob", "")
assert.NoError(t, tree.Populate())
defer tree.Squash()
names := lists.NewFileList().ListDir(tree.CWD)
m, err := model.New(tree.CWD, false, 1024*1024, 16)
assert.NoError(t, err)
_, err = m.IsBlobs(names...)
assert.NoError(t, err)
}
示例7: Test_Model_FeedManifests_Nil
func Test_Model_FeedManifests_Nil(t *testing.T) {
tree := fixtures.NewTree("feed-manifests", "")
assert.NoError(t, tree.Populate())
defer tree.Squash()
names := lists.NewFileList().ListDir(tree.CWD)
tree.KillBLOB("file-one.bin")
m, err := model.New(tree.CWD, false, 1024*1024, 16)
assert.NoError(t, err)
lx, err := m.FeedManifests(true, true, false, names...)
assert.Error(t, err)
assert.Len(t, lx.Names(), 15)
}
示例8: Test_Transport_CreateUpload
func Test_Transport_CreateUpload(t *testing.T) {
root := "DeclareUpload"
halt, tree, ml, _, tr := seed(t, root)
defer halt()
mx, err := ml.FeedManifests(true, true, true, lists.NewFileList().ListDir(tree.CWD)...)
assert.NoError(t, err)
upload := transport.NewUpload(tr, time.Hour)
toUp, err := upload.SendCreateUpload(mx)
assert.NoError(t, err)
assert.Len(t, toUp, 4)
}
示例9: Run
func (c *UpCmd) Run(args ...string) (err error) {
var mod *model.Model
if mod, err = model.New(c.WD, c.UseGit, c.ChunkSize, c.PoolSize); err != nil {
return
}
feed := lists.NewFileList(args...).ListDir(c.WD)
isDirty, dirty, err := mod.Check(feed...)
if err != nil {
return
}
if isDirty {
err = fmt.Errorf("dirty files in working tree %s", dirty)
return
}
if c.UseGit {
// filter by attrs
feed, err = mod.Git.FilterByAttr("bar", feed...)
}
blobs, err := mod.FeedManifests(true, false, true, feed...)
if err != nil {
return
}
logx.Debugf("collected blobs %s", blobs.IDMap())
trans := transport.NewTransport(mod, "", c.Endpoint, c.PoolSize)
err = trans.Upload(blobs)
if err != nil {
return
}
if c.Squash {
if err = mod.SquashBlobs(blobs); err != nil {
return
}
if c.UseGit {
err = mod.Git.UpdateIndex(blobs.Names()...)
}
}
return
}
示例10: Test_Model_FeedManifests_Many
func Test_Model_FeedManifests_Many(t *testing.T) {
if testing.Short() {
t.Skip()
}
tree := fixtures.NewTree("collect-manifests-large", "")
defer tree.Squash()
assert.NoError(t, tree.Populate())
assert.NoError(t, tree.PopulateN(10, 300))
names := lists.NewFileList().ListDir(tree.CWD)
m, err := model.New(tree.CWD, false, 1024*1024, 16)
assert.NoError(t, err)
lx, err := m.FeedManifests(true, true, true, names...)
assert.NoError(t, err)
assert.Len(t, lx.Names(), 316)
}
示例11: Test_Transport_UploadChunk
func Test_Transport_UploadChunk(t *testing.T) {
root := "UploadChunk"
halt, tree, ml, _, tr := seed(t, root)
defer halt()
mx, err := ml.FeedManifests(true, true, true, lists.NewFileList().ListDir(tree.CWD)...)
assert.NoError(t, err)
upload := transport.NewUpload(tr, time.Hour)
missing, err := upload.SendCreateUpload(mx)
assert.NoError(t, err)
toUp := mx.GetChunkLinkSlice(missing)
for _, tu := range toUp {
err = upload.UploadChunk(tu.Name, tu.Chunk)
assert.NoError(t, err)
}
}
示例12: Test_Transport_Check
func Test_Transport_Check(t *testing.T) {
root := "Check"
halt, tree, ml, _, tr := seed(t, root)
defer halt()
mx, err := ml.FeedManifests(true, true, true, lists.NewFileList().ListDir(tree.CWD)...)
assert.NoError(t, err)
err = tr.Upload(mx)
assert.NoError(t, err)
res, err := tr.Check([]proto.ID{
"eebd7b0c388d7f4d4ede4681b472969d5f09228c0473010d670a6918a3c05e79",
"eebd7b0c388d7f4d4ede4681b472969d5f09228c0473010d670a6918a3c05e7a",
})
assert.NoError(t, err)
assert.Equal(t, []proto.ID{
"eebd7b0c388d7f4d4ede4681b472969d5f09228c0473010d670a6918a3c05e7a",
}, res)
}
示例13: Benchmark_Model_FeedManifests_Large
func Benchmark_Model_FeedManifests_Large(b *testing.B) {
tree := fixtures.NewTree("collect-manifests-large-B", "")
defer tree.Squash()
assert.NoError(b, tree.Populate())
assert.NoError(b, tree.PopulateN(1024*1024*500, 5))
names := lists.NewFileList().ListDir(tree.CWD)
b.ResetTimer()
for i := 0; i < b.N; i++ {
b.StartTimer()
m, err := model.New(tree.CWD, false, 1024*1024, 16)
assert.NoError(b, err)
lx, err := m.FeedManifests(true, true, true, names...)
b.StopTimer()
assert.NoError(b, err)
for _, man := range lx {
b.SetBytes(man.Size)
}
}
}
示例14: Test_Storage_Upload_FinishUpload
func Test_Storage_Upload_FinishUpload(t *testing.T) {
logx.SetLevel(logx.DEBUG)
tree := fixtures.NewTree("finish-upload", "")
defer tree.Squash()
assert.NoError(t, tree.Populate())
m, err := model.New(tree.CWD, false, proto.CHUNK_SIZE, 16)
assert.NoError(t, err)
os.RemoveAll("testdata/finish-upload-storage")
stor := storage.NewBlockStorage(&storage.BlockStorageOptions{
"testdata/finish-upload-storage", 2, 16, 32,
})
defer os.RemoveAll("testdata/finish-upload-storage")
names := lists.NewFileList().ListDir(tree.CWD)
mans, err := m.FeedManifests(true, false, true, names...)
uID, _ := uuid.NewV4()
missing, err := stor.CreateUploadSession(*uID, mans.GetManifestSlice(), time.Hour)
assert.NoError(t, err)
toUpload := mans.GetChunkLinkSlice(missing)
for _, v := range toUpload {
r, err := os.Open(tree.BlobFilename(v.Name))
assert.NoError(t, err)
defer r.Close()
buf := make([]byte, v.Size)
_, err = r.ReadAt(buf, v.Offset)
err = stor.UploadChunk(*uID, v.Chunk.ID, bytes.NewReader(buf))
assert.NoError(t, err)
}
err = stor.FinishUploadSession(*uID)
assert.NoError(t, err)
}
示例15: Test_Transport_Download
func Test_Transport_Download(t *testing.T) {
root := "Download"
halt, tree, ml, _, tr := seed(t, root)
defer halt()
mx, err := ml.FeedManifests(true, true, true, lists.NewFileList().ListDir(tree.CWD)...)
assert.NoError(t, err)
err = tr.Upload(mx)
assert.NoError(t, err)
// Kill some blobs
tree.KillBLOB("file-two.bin")
tree.KillBLOB("one/file-two.bin")
tree.KillBLOB("one/file-three.bin")
err = tr.Download(lists.BlobMap{
"file-two.bin": mx["file-two.bin"],
"one/file-two.bin": mx["one/file-two.bin"],
"one/file-three.bin": mx["one/file-three.bin"],
})
assert.NoError(t, err)
}