-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rename data pkg Stream to Item #3966
Changes from all commits
d93c5b4
2aee842
576b57d
28100b7
988eabe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,54 @@ | ||||
package data | ||||
|
||||
import ( | ||||
"context" | ||||
|
||||
"github.com/alcionai/clues" | ||||
|
||||
"github.com/alcionai/corso/src/pkg/path" | ||||
) | ||||
|
||||
var ErrNotFound = clues.New("not found") | ||||
|
||||
type CollectionState int | ||||
|
||||
const ( | ||||
NewState = CollectionState(iota) | ||||
NotMovedState | ||||
MovedState | ||||
DeletedState | ||||
) | ||||
|
||||
type FetchRestoreCollection struct { | ||||
Collection | ||||
FetchItemByNamer | ||||
} | ||||
|
||||
// NoFetchRestoreCollection is a wrapper for a Collection that returns | ||||
// ErrNotFound for all Fetch calls. | ||||
type NoFetchRestoreCollection struct { | ||||
Collection | ||||
FetchItemByNamer | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I know this is code movement, but this field should be removed. We're providing a function that gives this functionality, not using an embedded interface
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll fix that in a follow-up PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||
} | ||||
|
||||
func (c NoFetchRestoreCollection) FetchItemByName(context.Context, string) (Item, error) { | ||||
return nil, ErrNotFound | ||||
} | ||||
|
||||
// StateOf lets us figure out the state of the collection from the | ||||
// previous and current path | ||||
func StateOf(prev, curr path.Path) CollectionState { | ||||
if curr == nil || len(curr.String()) == 0 { | ||||
return DeletedState | ||||
} | ||||
|
||||
if prev == nil || len(prev.String()) == 0 { | ||||
return NewState | ||||
} | ||||
|
||||
if curr.String() != prev.String() { | ||||
return MovedState | ||||
} | ||||
|
||||
return NotMovedState | ||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved out of /data/collections to separate interfaces and non-interfaces (the code was getting jumbled in there). Only movement, nothing new/changed.