Skip to content

Commit a85133a

Browse files
adding ignored containers to info log
1 parent e07cf9f commit a85133a

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

cmd/zc_traverser_blob_account.go

+13-4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"fmt"
2626
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/service"
2727
"github.com/Azure/azure-storage-azcopy/v10/common"
28+
"strings"
2829
)
2930

3031
// Enumerates an entire blob account, looking into each matching container as it goes
@@ -53,14 +54,20 @@ func (t *blobAccountTraverser) IsDirectory(_ bool) (bool, error) {
5354
}
5455

5556
func (t *blobAccountTraverser) listContainers() ([]string, error) {
57+
cachedContainers, _, err := t.getListContainers()
58+
return cachedContainers, err
59+
}
60+
61+
func (t *blobAccountTraverser) getListContainers() ([]string, []string, error) {
62+
var skippedContainers []string
5663
// a nil list also returns 0
5764
if len(t.cachedContainers) == 0 || len(t.excludeContainerName) > 0 {
5865
cList := make([]string, 0)
5966
pager := t.serviceClient.NewListContainersPager(nil)
6067
for pager.More() {
6168
resp, err := pager.NextPage(t.ctx)
6269
if err != nil {
63-
return nil, err
70+
return nil, nil, err
6471
}
6572
for _, v := range resp.ContainerItems {
6673
// a nil list also returns 0
@@ -69,7 +76,7 @@ func (t *blobAccountTraverser) listContainers() ([]string, error) {
6976
if t.containerPattern != "" {
7077
if ok, err := containerNameMatchesPattern(*v.Name, t.containerPattern); err != nil {
7178
// Break if the pattern is invalid
72-
return nil, err
79+
return nil, nil, err
7380
} else if !ok {
7481
// Ignore the container if it doesn't match the pattern.
7582
continue
@@ -83,6 +90,7 @@ func (t *blobAccountTraverser) listContainers() ([]string, error) {
8390
for _, f := range t.excludeContainerName {
8491
if !f.DoesPass(so) {
8592
// Ignore the container if the container name should be excluded
93+
skippedContainers = append(skippedContainers, *v.Name)
8694
continue
8795
} else {
8896
cList = append(cList, *v.Name)
@@ -96,12 +104,13 @@ func (t *blobAccountTraverser) listContainers() ([]string, error) {
96104
t.cachedContainers = cList
97105
}
98106

99-
return t.cachedContainers, nil
107+
return t.cachedContainers, skippedContainers, nil
100108
}
101109

102110
func (t *blobAccountTraverser) Traverse(preprocessor objectMorpher, processor objectProcessor, filters []ObjectFilter) error {
103111
// listContainers will return the cached container list if containers have already been listed by this traverser.
104-
cList, err := t.listContainers()
112+
cList, skippedContainers, err := t.getListContainers()
113+
glcm.Info("Skipped container(s): " + strings.Join(skippedContainers, ", "))
105114

106115
if err != nil {
107116
return err

0 commit comments

Comments
 (0)