Folder display name fix (#3062)

Fixes folder display names in backup details.
They got off when locations were switched to
returning path builders instead of full paths

---

#### Does this PR need a docs update or release note?

- [ ]  Yes, it's included
- [ ] 🕐 Yes, but in a later PR
- [x]  No

#### Type of change

- [ ] 🌻 Feature
- [x] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Supportability/Tests
- [ ] 💻 CI/Deployment
- [ ] 🧹 Tech Debt/Cleanup

#### Issue
- closes #3061

#### Test Plan

- [x] 💪 Manual
- [ ]  Unit test
- [ ] 💚 E2E
This commit is contained in:
ashmrtn 2023-04-06 22:34:28 -07:00 committed by GitHub
parent 3cc29649ed
commit dae79f4acf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 28 deletions

View File

@ -2,7 +2,6 @@ package backup
import ( import (
"context" "context"
"fmt"
"github.com/alcionai/clues" "github.com/alcionai/clues"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -170,8 +169,6 @@ func createExchangeCmd(cmd *cobra.Command, args []string) error {
return Only(ctx, clues.Wrap(err, "Failed to retrieve M365 users")) return Only(ctx, clues.Wrap(err, "Failed to retrieve M365 users"))
} }
fmt.Printf("\n-----\nINS %+v\n-----\n", ins)
selectorSet := []selectors.Selector{} selectorSet := []selectors.Selector{}
for _, discSel := range sel.SplitByResourceOwner(ins.IDs()) { for _, discSel := range sel.SplitByResourceOwner(ins.IDs()) {

View File

@ -171,7 +171,7 @@ func (b *Builder) Details() *Details {
// AddFoldersForItem, and unexport AddFoldersForItem. // AddFoldersForItem, and unexport AddFoldersForItem.
func FolderEntriesForPath(parent, location *path.Builder) []folderEntry { func FolderEntriesForPath(parent, location *path.Builder) []folderEntry {
folders := []folderEntry{} folders := []folderEntry{}
lfs := locationRefOf(location) lfs := location
for len(parent.Elements()) > 0 { for len(parent.Elements()) > 0 {
var ( var (
@ -213,21 +213,6 @@ func FolderEntriesForPath(parent, location *path.Builder) []folderEntry {
return folders return folders
} }
// assumes the pb contains a path like:
// <tenant>/<service>/<owner>/<category>/<logical_containers>...
// and returns a string with only <logical_containers>/...
func locationRefOf(pb *path.Builder) *path.Builder {
if pb == nil {
return nil
}
for i := 0; i < 4; i++ {
pb = pb.PopFront()
}
return pb
}
// AddFoldersForItem adds entries for the given folders. It skips adding entries that // AddFoldersForItem adds entries for the given folders. It skips adding entries that
// have been added by previous calls. // have been added by previous calls.
func (b *Builder) AddFoldersForItem(folders []folderEntry, itemInfo ItemInfo, updated bool) { func (b *Builder) AddFoldersForItem(folders []folderEntry, itemInfo ItemInfo, updated bool) {

View File

@ -1138,12 +1138,6 @@ func (suite *DetailsUnitSuite) TestFolderEntriesForPath() {
parent: basePath, parent: basePath,
expect: baseFolderEnts, expect: baseFolderEnts,
}, },
{
name: "base path with location",
parent: basePath,
location: basePath,
expect: baseFolderEnts,
},
{ {
name: "single depth parent only", name: "single depth parent only",
parent: basePath.Append(fnords...), parent: basePath.Append(fnords...),
@ -1152,7 +1146,7 @@ func (suite *DetailsUnitSuite) TestFolderEntriesForPath() {
{ {
name: "single depth with location", name: "single depth with location",
parent: basePath.Append(fnords...), parent: basePath.Append(fnords...),
location: basePath.Append(beau...), location: path.Builder{}.Append(beau...),
expect: folderEntriesFor(fnords, beau), expect: folderEntriesFor(fnords, beau),
}, },
{ {
@ -1163,13 +1157,13 @@ func (suite *DetailsUnitSuite) TestFolderEntriesForPath() {
{ {
name: "two depth with location", name: "two depth with location",
parent: basePath.Append(smarf...), parent: basePath.Append(smarf...),
location: basePath.Append(regard...), location: path.Builder{}.Append(regard...),
expect: folderEntriesFor(smarf, regard), expect: folderEntriesFor(smarf, regard),
}, },
{ {
name: "mismatched depth, parent longer", name: "mismatched depth, parent longer",
parent: basePath.Append(smarf...), parent: basePath.Append(smarf...),
location: basePath.Append(beau...), location: path.Builder{}.Append(beau...),
expect: folderEntriesFor(smarf, beau), expect: folderEntriesFor(smarf, beau),
}, },
// We can't handle this right now. But we don't have any cases // We can't handle this right now. But we don't have any cases