Skip to content

Commit

Permalink
resolving comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ashruti-msft committed Oct 18, 2024
1 parent 046faf6 commit 5d5fda9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
12 changes: 6 additions & 6 deletions common/trieForDirPath.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

type TrieNode struct {
Children map[string]*TrieNode
Value *uint32
Value uint32
isEnd bool
}

Expand All @@ -31,24 +31,24 @@ func (t *Trie) Insert(key string, value uint32) {
}
node = child
}
node.Value = &value
node.Value = value
node.isEnd = true
}

func (t *Trie) Get(key string) (*uint32, bool) {
func (t *Trie) Get(key string) (uint32, bool) {
node := t.Root
segments := strings.Split(key, "/")
for _, segment := range segments {
child, exists := node.Children[segment]
if !exists {
return nil, false
return 0, false
}
node = child
}
if node.isEnd {
return node.Value, true
}
return nil, false
return 0, false
}

func (t *Trie) Delete(key string) bool {
Expand All @@ -67,7 +67,7 @@ func (t *Trie) deleteHelper(node *TrieNode, segments []string, depth int) bool {
return false // Key does not exist
}
node.isEnd = false // Unmark the end of the key
node.Value = nil
node.Value = 0

// If the node has no Children, it can be deleted
return len(node.Children) == 0
Expand Down
9 changes: 6 additions & 3 deletions ste/folderCreationTracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (f *jpptFolderTracker) CreateFolder(folder string, doCreation func() error)
}

if idx, ok := f.contents.Get(folder); ok {
status := f.plan.Transfer(*idx).TransferStatus()
status := f.plan.Transfer(idx).TransferStatus()
if status == (common.ETransferStatus.FolderCreated()) || status == (common.ETransferStatus.Success()) {
return nil
}
Expand All @@ -103,7 +103,7 @@ func (f *jpptFolderTracker) CreateFolder(folder string, doCreation func() error)

if idx, ok := f.contents.Get(folder); ok {
// overwrite it's transfer status
f.plan.Transfer(*idx).SetTransferStatus(common.ETransferStatus.FolderCreated(), false)
f.plan.Transfer(idx).SetTransferStatus(common.ETransferStatus.FolderCreated(), false)
} else {
// A folder hasn't been hit in traversal yet.
// Recording it in memory is OK, because we *cannot* resume a job that hasn't finished traversal.
Expand All @@ -130,7 +130,10 @@ func (f *jpptFolderTracker) ShouldSetProperties(folder string, overwrite common.

var created bool
if idx, ok := f.contents.Get(folder); ok {
created = f.plan.Transfer(*idx).TransferStatus() == common.ETransferStatus.FolderCreated()
status := f.plan.Transfer(idx).TransferStatus()
if status == (common.ETransferStatus.FolderCreated()) || status == (common.ETransferStatus.Success()) {
created = true
}
} else {
// This should not happen, ever.
// Folder property jobs register with the tracker before they start getting processed.
Expand Down

0 comments on commit 5d5fda9

Please sign in to comment.