Skip to content

Commit 5ede135

Browse files
authored
Merge pull request #1765 from anyproto/release-7-fix
Release 7 fix
2 parents 3774652 + 50df1d6 commit 5ede135

File tree

3 files changed

+13
-42
lines changed

3 files changed

+13
-42
lines changed

core/syncstatus/detailsupdater/updater.go

+7-36
Original file line numberDiff line numberDiff line change
@@ -206,20 +206,8 @@ func (u *syncStatusUpdater) updateObjectDetails(syncStatusDetails *syncStatusDet
206206
if details == nil || details.Fields == nil {
207207
details = &types.Struct{Fields: map[string]*types.Value{}}
208208
}
209-
if !u.isLayoutSuitableForSyncRelations(details) || pbtypes.GetString(details, bundle.RelationKeySpaceId.String()) == "" {
210-
var syncRelations = []string{
211-
bundle.RelationKeySyncStatus.String(),
212-
bundle.RelationKeySyncError.String(),
213-
bundle.RelationKeySyncDate.String(),
214-
}
215-
modified := false
216-
for _, relation := range syncRelations {
217-
if _, ok := details.GetFields()[relation]; ok {
218-
delete(details.Fields, relation)
219-
modified = true
220-
}
221-
}
222-
return details, modified, nil
209+
if !u.isLayoutSuitableForSyncRelations(details) {
210+
return details, false, nil
223211
}
224212
if fileStatus, ok := details.GetFields()[bundle.RelationKeyFileBackupStatus.String()]; ok {
225213
status, syncError = getSyncStatusForFile(status, syncError, filesyncstatus.Status(int(fileStatus.GetNumberValue())))
@@ -242,28 +230,11 @@ func (u *syncStatusUpdater) updateObjectDetails(syncStatusDetails *syncStatusDet
242230
}
243231

244232
func (u *syncStatusUpdater) setSyncDetails(sb smartblock.SmartBlock, status domain.ObjectSyncStatus, syncError domain.SyncError) error {
245-
var (
246-
st = sb.NewState()
247-
details = sb.CombinedDetails()
248-
)
249-
if !slices.Contains(helper.SyncRelationsSmartblockTypes(), sb.Type()) ||
250-
!u.isLayoutSuitableForSyncRelations(details) ||
251-
pbtypes.GetString(details, bundle.RelationKeySpaceId.String()) == "" { // this was the case with incorrectly indexed objects
252-
var syncRelations = []string{
253-
bundle.RelationKeySyncStatus.String(),
254-
bundle.RelationKeySyncError.String(),
255-
bundle.RelationKeySyncDate.String(),
256-
}
257-
removedOnce := false
258-
for _, relation := range syncRelations {
259-
if st.HasRelation(relation) {
260-
removedOnce = true
261-
st.RemoveRelation(relation)
262-
}
263-
}
264-
if removedOnce {
265-
return sb.Apply(st, smartblock.KeepInternalFlags /* do not erase flags */)
266-
}
233+
if !slices.Contains(helper.SyncRelationsSmartblockTypes(), sb.Type()) {
234+
return nil
235+
}
236+
st := sb.NewState()
237+
if !u.isLayoutSuitableForSyncRelations(sb.Details()) {
267238
return nil
268239
}
269240
if fileStatus, ok := st.Details().GetFields()[bundle.RelationKeyFileBackupStatus.String()]; ok {

core/syncstatus/detailsupdater/updater_test.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ func TestSyncStatusUpdater_UpdateDetails(t *testing.T) {
100100
sb := smarttest.New(objectId)
101101
st := sb.Doc.(*state.State)
102102
st.SetDetailAndBundledRelation(bundle.RelationKeyLayout, pbtypes.Int64(int64(model.ObjectType_basic)))
103-
st.SetDetailAndBundledRelation(bundle.RelationKeySpaceId, pbtypes.String("spaceId"))
104103
err := apply(sb)
105104
require.NoError(t, err)
106105

@@ -167,7 +166,6 @@ func TestSyncStatusUpdater_UpdateDetails(t *testing.T) {
167166
space.EXPECT().DoCtx(mock.Anything, mock.Anything, mock.Anything).Run(func(ctx context.Context, objectId string, apply func(smartblock.SmartBlock) error) {
168167
sb := smarttest.New(objectId)
169168
st := sb.Doc.(*state.State)
170-
st.SetDetailAndBundledRelation(bundle.RelationKeySpaceId, pbtypes.String("spaceId"))
171169
st.SetDetailAndBundledRelation(bundle.RelationKeyLayout, pbtypes.Int64(int64(model.ObjectType_file)))
172170
st.SetDetailAndBundledRelation(bundle.RelationKeyFileBackupStatus, pbtypes.Int64(int64(filesyncstatus.Limited)))
173171
err := apply(sb)
@@ -197,7 +195,6 @@ func TestSyncStatusUpdater_UpdateDetails(t *testing.T) {
197195
space.EXPECT().DoCtx(mock.Anything, mock.Anything, mock.Anything).Run(func(ctx context.Context, objectId string, apply func(smartblock.SmartBlock) error) {
198196
sb := smarttest.New(objectId)
199197
st := sb.Doc.(*state.State)
200-
st.SetDetailAndBundledRelation(bundle.RelationKeySpaceId, pbtypes.String("spaceId"))
201198
st.SetDetailAndBundledRelation(bundle.RelationKeyLayout, pbtypes.Int64(int64(model.ObjectType_file)))
202199
st.SetDetailAndBundledRelation(bundle.RelationKeyFileBackupStatus, pbtypes.Int64(int64(filesyncstatus.Synced)))
203200
err := apply(sb)
@@ -249,7 +246,6 @@ func TestSyncStatusUpdater_UpdateSpaceDetails(t *testing.T) {
249246
space.EXPECT().DoCtx(mock.Anything, objectId, mock.Anything).Run(func(ctx context.Context, objectId string, apply func(smartblock.SmartBlock) error) {
250247
sb := smarttest.New(objectId)
251248
st := sb.Doc.(*state.State)
252-
st.SetDetailAndBundledRelation(bundle.RelationKeySpaceId, pbtypes.String("spaceId"))
253249
st.SetDetailAndBundledRelation(bundle.RelationKeyLayout, pbtypes.Int64(int64(model.ObjectType_basic)))
254250
err := apply(sb)
255251
require.NoError(t, err)
@@ -283,8 +279,7 @@ func TestSyncStatusUpdater_setSyncDetails(t *testing.T) {
283279
// given
284280
fx := newFixture(t)
285281
sb := smarttest.New("id")
286-
st := sb.Doc.(*state.State)
287-
st.SetDetailAndBundledRelation(bundle.RelationKeySpaceId, pbtypes.String("spaceId"))
282+
288283
// when
289284
err := fx.setSyncDetails(sb, domain.ObjectSyncStatusError, domain.SyncErrorNetworkError)
290285
assert.Nil(t, err)

core/syncstatus/syncsubscriptions/syncingobjects.go

+5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ func (s *syncingObjects) Run() error {
3838
Condition: model.BlockContentDataviewFilter_In,
3939
Value: pbtypes.IntList(int(domain.SpaceSyncStatusSyncing), int(domain.ObjectSyncStatusQueued), int(domain.ObjectSyncStatusError)),
4040
},
41+
{
42+
RelationKey: bundle.RelationKeySpaceId.String(),
43+
Condition: model.BlockContentDataviewFilter_Equal,
44+
Value: pbtypes.String(s.spaceId),
45+
},
4146
},
4247
}
4348
s.objectSubscription = objectsubscription.NewIdSubscription(s.service, objectReq)

0 commit comments

Comments
 (0)