mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 05:57:03 +09:00
Fix acl issues, better error checks
This commit is contained in:
parent
95cfbf2339
commit
798e292ff0
4 changed files with 8 additions and 8 deletions
|
@ -222,7 +222,7 @@ func (a *aclList) AddRawRecord(rawRec *consensusproto.RawRecordWithId) (err erro
|
|||
RawRecord: rawRec.Payload,
|
||||
PrevId: record.PrevId,
|
||||
Id: record.Id,
|
||||
Order: len(a.records) + 1,
|
||||
Order: len(a.records),
|
||||
ChangeSize: len(rawRec.Payload),
|
||||
}
|
||||
return a.storage.AddAll(context.Background(), []StorageRecord{storageRec})
|
||||
|
|
|
@ -217,7 +217,7 @@ func (s *storage) AddAll(ctx context.Context, records []StorageRecord) error {
|
|||
err = s.headStorage.UpdateEntryTx(tx.Context(), update)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
return tx.Commit()
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ func (s *spaceService) CreateSpace(ctx context.Context, payload SpaceCreatePaylo
|
|||
}
|
||||
store, err := s.createSpaceStorage(ctx, storageCreate)
|
||||
if err != nil {
|
||||
if err == spacestorage.ErrSpaceStorageExists {
|
||||
if errors.Is(err, spacestorage.ErrSpaceStorageExists) {
|
||||
return storageCreate.SpaceHeaderWithId.Id, nil
|
||||
}
|
||||
return
|
||||
|
@ -132,7 +132,7 @@ func (s *spaceService) DeriveSpace(ctx context.Context, payload SpaceDerivePaylo
|
|||
}
|
||||
store, err := s.createSpaceStorage(ctx, storageCreate)
|
||||
if err != nil {
|
||||
if err == spacestorage.ErrSpaceStorageExists {
|
||||
if errors.Is(err, spacestorage.ErrSpaceStorageExists) {
|
||||
return storageCreate.SpaceHeaderWithId.Id, nil
|
||||
}
|
||||
return
|
||||
|
@ -144,7 +144,7 @@ func (s *spaceService) DeriveSpace(ctx context.Context, payload SpaceDerivePaylo
|
|||
func (s *spaceService) NewSpace(ctx context.Context, id string, deps Deps) (Space, error) {
|
||||
st, err := s.storageProvider.WaitSpaceStorage(ctx, id)
|
||||
if err != nil {
|
||||
if err != spacestorage.ErrSpaceStorageMissing {
|
||||
if !errors.Is(err, spacestorage.ErrSpaceStorageMissing) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ func (s *spaceService) addSpaceStorage(ctx context.Context, spaceDescription Spa
|
|||
st, err = s.createSpaceStorage(ctx, payload)
|
||||
if err != nil {
|
||||
err = spacesyncproto.ErrUnexpected
|
||||
if err == spacestorage.ErrSpaceStorageExists {
|
||||
if errors.Is(err, spacestorage.ErrSpaceStorageExists) {
|
||||
err = spacesyncproto.ErrSpaceExists
|
||||
}
|
||||
return
|
||||
|
|
|
@ -115,7 +115,7 @@ func (s *service) Init(a *app.App) (err error) {
|
|||
s.source = a.MustComponent(CNameSource).(Source)
|
||||
s.store = a.MustComponent(CNameStore).(Store)
|
||||
lastStored, err := s.store.GetLast(context.Background(), s.config.NetworkId)
|
||||
if err == ErrConfigurationNotFound {
|
||||
if errors.Is(err, ErrConfigurationNotFound) {
|
||||
lastStored = s.config
|
||||
err = nil
|
||||
} else {
|
||||
|
@ -139,7 +139,7 @@ func (s *service) Init(a *app.App) (err error) {
|
|||
s.sync = periodicsync.NewPeriodicSync(updatePeriodSec, 0, func(ctx context.Context) (err error) {
|
||||
err = s.updateConfiguration(ctx)
|
||||
if err != nil {
|
||||
if err == ErrConfigurationNotChanged || err == ErrConfigurationNotFound {
|
||||
if errors.Is(err, ErrConfigurationNotChanged) || errors.Is(err, ErrConfigurationNotFound) {
|
||||
err = nil
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue