Skip to content

Commit 4dd5f1b

Browse files
Fix handling of env variable (#1686)
1 parent 5358431 commit 4dd5f1b

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

cmd/zc_traverser_blob.go

+9-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"context"
2525
"fmt"
2626
"net/url"
27-
"os"
2827
"strings"
2928

3029
"github.com/Azure/azure-storage-azcopy/v10/common/parallel"
@@ -447,11 +446,6 @@ func (t *blobTraverser) serialList(containerURL azblob.ContainerURL, containerNa
447446
}
448447

449448
func newBlobTraverser(rawURL *url.URL, p pipeline.Pipeline, ctx context.Context, recursive, includeDirectoryStubs bool, incrementEnumerationCounter enumerationCounterFunc, s2sPreserveSourceTags bool, cpkOptions common.CpkOptions, includeDeleted, includeSnapshot, includeVersion bool) (t *blobTraverser) {
450-
if strings.ToLower(glcm.GetEnvironmentVariable(common.EEnvironmentVariable.DisableHierarchicalScanning())) == "false" &&
451-
includeDeleted && (includeSnapshot || includeVersion) {
452-
os.Setenv("AZCOPY_DISABLE_HIERARCHICAL_SCAN", "true")
453-
fmt.Println("AZCOPY_DISABLE_HIERARCHICAL_SCAN has been set to true to permanently delete soft-deleted snapshots/versions.")
454-
}
455449
t = &blobTraverser{
456450
rawURL: rawURL,
457451
p: p,
@@ -467,7 +461,15 @@ func newBlobTraverser(rawURL *url.URL, p pipeline.Pipeline, ctx context.Context,
467461
includeVersion: includeVersion,
468462
}
469463

470-
if strings.ToLower(glcm.GetEnvironmentVariable(common.EEnvironmentVariable.DisableHierarchicalScanning())) == "true" {
464+
disableHierarchicalScanning := strings.ToLower(glcm.GetEnvironmentVariable(common.EEnvironmentVariable.DisableHierarchicalScanning()))
465+
466+
// disableHierarchicalScanning should be true for permanent delete
467+
if (disableHierarchicalScanning == "false" || disableHierarchicalScanning == "") && includeDeleted && (includeSnapshot || includeVersion) {
468+
t.parallelListing = false
469+
fmt.Println("AZCOPY_DISABLE_HIERARCHICAL_SCAN has been set to true to permanently delete soft-deleted snapshots/versions.")
470+
}
471+
472+
if disableHierarchicalScanning == "true" {
471473
// TODO log to frontend log that parallel listing was disabled, once the frontend log PR is merged
472474
t.parallelListing = false
473475
}

0 commit comments

Comments
 (0)