Fix settings document
This commit is contained in:
parent
f988ba9206
commit
d23f36d364
@ -124,16 +124,6 @@ func (s *service) NewSpace(ctx context.Context, id string) (Space, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) addSpaceStorage(ctx context.Context, spaceDescription SpaceDescription) (st storage.SpaceStorage, err error) {
|
func (s *service) addSpaceStorage(ctx context.Context, spaceDescription SpaceDescription) (st storage.SpaceStorage, err error) {
|
||||||
_, err = s.storageProvider.SpaceStorage(spaceDescription.SpaceHeader.Id)
|
|
||||||
if err == nil {
|
|
||||||
err = spacesyncproto.ErrSpaceExists
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err != storage.ErrSpaceStorageMissing {
|
|
||||||
err = spacesyncproto.ErrUnexpected
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
payload := storage.SpaceStorageCreatePayload{
|
payload := storage.SpaceStorageCreatePayload{
|
||||||
AclWithId: &aclrecordproto.RawACLRecordWithId{
|
AclWithId: &aclrecordproto.RawACLRecordWithId{
|
||||||
Payload: spaceDescription.AclPayload,
|
Payload: spaceDescription.AclPayload,
|
||||||
|
|||||||
@ -41,7 +41,7 @@ type settingsDocument struct {
|
|||||||
store spacestorage.SpaceStorage
|
store spacestorage.SpaceStorage
|
||||||
prov deletedIdsProvider
|
prov deletedIdsProvider
|
||||||
buildFunc BuildTreeFunc
|
buildFunc BuildTreeFunc
|
||||||
loop deleteLoop
|
loop *deleteLoop
|
||||||
|
|
||||||
deletionState *deletionstate.DeletionState
|
deletionState *deletionstate.DeletionState
|
||||||
lastChangeId string
|
lastChangeId string
|
||||||
@ -57,6 +57,7 @@ func NewSettingsDocument(deps Deps, spaceId string) (doc SettingsDocument, err e
|
|||||||
})
|
})
|
||||||
|
|
||||||
s := &settingsDocument{
|
s := &settingsDocument{
|
||||||
|
loop: loop,
|
||||||
spaceId: spaceId,
|
spaceId: spaceId,
|
||||||
account: deps.Account,
|
account: deps.Account,
|
||||||
deletionState: deps.DeletionState,
|
deletionState: deps.DeletionState,
|
||||||
@ -74,9 +75,9 @@ func NewSettingsDocument(deps Deps, spaceId string) (doc SettingsDocument, err e
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *settingsDocument) updateIds(lastChangeId string) {
|
func (s *settingsDocument) updateIds(tr tree.ObjectTree, lastChangeId string) {
|
||||||
s.lastChangeId = lastChangeId
|
s.lastChangeId = lastChangeId
|
||||||
ids, lastId, err := s.prov.ProvideIds(s, s.lastChangeId)
|
ids, lastId, err := s.prov.ProvideIds(tr, s.lastChangeId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(zap.Strings("ids", ids), zap.Error(err)).Error("failed to update state")
|
log.With(zap.Strings("ids", ids), zap.Error(err)).Error("failed to update state")
|
||||||
return
|
return
|
||||||
@ -88,11 +89,12 @@ func (s *settingsDocument) updateIds(lastChangeId string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *settingsDocument) Update(tr tree.ObjectTree) {
|
func (s *settingsDocument) Update(tr tree.ObjectTree) {
|
||||||
s.updateIds(s.lastChangeId)
|
s.updateIds(tr, s.lastChangeId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *settingsDocument) Rebuild(tr tree.ObjectTree) {
|
func (s *settingsDocument) Rebuild(tr tree.ObjectTree) {
|
||||||
s.updateIds("")
|
// at initial build "s" may not contain the object tree, so it is safer to provide it from the function parameter
|
||||||
|
s.updateIds(tr, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *settingsDocument) Init(ctx context.Context) (err error) {
|
func (s *settingsDocument) Init(ctx context.Context) (err error) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user