2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-26 20:30:19 +00:00

Azure: Fix List(), use pagination marker

This commit is contained in:
Alexander Neumann 2017-09-17 11:32:05 +02:00
parent f61dab1774
commit dd49e2b12d

View File

@ -264,25 +264,39 @@ func (be *Backend) List(ctx context.Context, t restic.FileType) <-chan string {
prefix += "/"
}
params := storage.ListBlobsParameters{
MaxResults: 1000,
Prefix: prefix,
}
go func() {
defer close(ch)
obj, err := be.container.ListBlobs(storage.ListBlobsParameters{Prefix: prefix})
if err != nil {
return
}
for _, item := range obj.Blobs {
m := strings.TrimPrefix(item.Name, prefix)
if m == "" {
continue
}
select {
case ch <- path.Base(m):
case <-ctx.Done():
for {
obj, err := be.container.ListBlobs(params)
if err != nil {
return
}
debug.Log("got %v objects", len(obj.Blobs))
for _, item := range obj.Blobs {
m := strings.TrimPrefix(item.Name, prefix)
if m == "" {
continue
}
select {
case ch <- path.Base(m):
case <-ctx.Done():
return
}
}
if obj.NextMarker == "" {
break
}
params.Marker = obj.NextMarker
}
}()