Skip to content
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

fix: Preserve not_synchronized_on on shared dirs #4150

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions model/sharing/files_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package sharing

import (
"strings"
"testing"
"time"

Expand Down Expand Up @@ -215,13 +216,22 @@ func TestFiles(t *testing.T) {
assert.Equal(t, "/Tree Shared with me/Test update dir/Foo", dir.Fullpath)
}

// Exclude dir from synchronization on a Desktop client
dir.NotSynchronizedOn = append(dir.NotSynchronizedOn,
couchdb.DocReference{ID: "ea24f891a41bf1f433460d20706d22c9", Type: "io.cozy.oauth.clients"},
)
err = couchdb.UpdateDoc(inst, dir)
require.NoError(t, err)
newTargetRev := strings.SplitN(dir.Rev(), "-", 2)[1]

target = map[string]interface{}{
"_id": idFoo,
"_rev": "2-96c72d35f3ad802484a61df501b0f1bb",
"_rev": "3-96c72d35f3ad802484a61df501b0f1bb",
"_revisions": map[string]interface{}{
"start": float64(2),
"start": float64(3),
"ids": []interface{}{
"96c72d35f3ad802484a61df501b0f1bb",
newTargetRev,
"4fff5291a41bf1f493460d2070694c5a",
},
},
Expand All @@ -244,6 +254,7 @@ func TestFiles(t *testing.T) {
assert.Equal(t, "2018-04-13 15:06:00.012345678 +0100 +0100", dir.CreatedAt.String())
assert.Equal(t, "2018-04-13 15:10:57.364765745 +0100 +0100", dir.UpdatedAt.String())
assert.Equal(t, []string{"quux", "courge"}, dir.Tags)
assert.Equal(t, []couchdb.DocReference{{ID: "ea24f891a41bf1f433460d20706d22c9", Type: "io.cozy.oauth.clients"}}, dir.NotSynchronizedOn)
}
})

Expand Down
3 changes: 3 additions & 0 deletions model/sharing/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ func (s *sharingIndexer) UpdateDirDoc(olddoc, doc *vfs.DirDoc) error {
if len(doc.ReferencedBy) > 0 {
docs[0][couchdb.SelectorReferencedBy] = doc.ReferencedBy
}
if len(doc.NotSynchronizedOn) > 0 {
docs[0]["not_synchronized_on"] = doc.NotSynchronizedOn
}
if doc.Metadata != nil {
docs[0]["metadata"] = doc.Metadata
}
Expand Down
Loading