Skip to content

Commit

Permalink
Merge pull request #371 from abdasgupta/working
Browse files Browse the repository at this point in the history
Handled properly potential of wrong prefix formation in Azure.
  • Loading branch information
abdasgupta authored Aug 12, 2021
2 parents 24999e1 + e4b6d71 commit 0c5e6e3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/snapstore/abs_snapstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,12 @@ func (a *ABSSnapStore) Fetch(snap brtypes.Snapshot) (io.ReadCloser, error) {
return resp.Body(azblob.RetryReaderOptions{}), nil
}

// List will list all snapshot files on store
// List will return sorted list with all snapshot files on store.
func (a *ABSSnapStore) List() (brtypes.SnapList, error) {
prefixTokens := strings.Split(a.prefix, "/")
// Last element of the tokens is backup version
// Consider the parent of the backup version level (Required for Backward Compatibility)
prefix := path.Join(strings.Join(prefixTokens[:len(prefixTokens)-1], "/"))

var snapList brtypes.SnapList
opts := azblob.ListBlobsSegmentOptions{Prefix: prefix}
for marker := (azblob.Marker{}); marker.NotDone(); {
Expand All @@ -131,7 +130,9 @@ func (a *ABSSnapStore) List() (brtypes.SnapList, error) {
// Process the blobs returned in this result segment
for _, blob := range listBlob.Segment.BlobItems {
if strings.Contains(blob.Name, backupVersionV1) || strings.Contains(blob.Name, backupVersionV2) {
s, err := ParseSnapshot(path.Join(prefix, blob.Name))
//the blob may contain the full path in its name including the prefix
blobName := strings.TrimPrefix(blob.Name, prefix)
s, err := ParseSnapshot(path.Join(prefix, blobName))
if err != nil {
logrus.Warnf("Invalid snapshot found. Ignoring it:%s\n", blob.Name)
} else {
Expand Down

0 comments on commit 0c5e6e3

Please sign in to comment.