This commit is contained in:
@@ -312,14 +312,15 @@ func (r *indexSenderRegistry) addLocked(folder config.FolderConfiguration, fset
|
||||
}
|
||||
|
||||
is := &indexSender{
|
||||
conn: r.conn,
|
||||
connClosed: r.closed,
|
||||
folder: folder.ID,
|
||||
fset: fset,
|
||||
prevSequence: startSequence,
|
||||
evLogger: r.evLogger,
|
||||
pauseChan: make(chan struct{}),
|
||||
resumeChan: make(chan *db.FileSet),
|
||||
conn: r.conn,
|
||||
connClosed: r.closed,
|
||||
folder: folder.ID,
|
||||
folderIsReceiveEncrypted: folder.Type == config.FolderTypeReceiveEncrypted,
|
||||
fset: fset,
|
||||
prevSequence: startSequence,
|
||||
evLogger: r.evLogger,
|
||||
pauseChan: make(chan struct{}),
|
||||
resumeChan: make(chan *db.FileSet),
|
||||
}
|
||||
is.token = r.sup.Add(is)
|
||||
r.indexSenders[folder.ID] = is
|
||||
|
||||
@@ -1334,3 +1334,67 @@ func TestRequestIndexSenderClusterConfigBeforeStart(t *testing.T) {
|
||||
case <-indexChan:
|
||||
}
|
||||
}
|
||||
|
||||
func TestRequestReceiveEncryptedLocalNoSend(t *testing.T) {
|
||||
w, fcfg := tmpDefaultWrapper()
|
||||
tfs := fcfg.Filesystem()
|
||||
fcfg.Type = config.FolderTypeReceiveEncrypted
|
||||
waiter, err := w.SetFolder(fcfg)
|
||||
must(t, err)
|
||||
waiter.Wait()
|
||||
|
||||
encToken := protocol.PasswordToken(fcfg.ID, "pw")
|
||||
must(t, tfs.Mkdir(config.DefaultMarkerName, 0777))
|
||||
must(t, writeEncryptionToken(encToken, fcfg))
|
||||
|
||||
m := setupModel(w)
|
||||
defer cleanupModelAndRemoveDir(m, tfs.URI())
|
||||
|
||||
fc := &fakeConnection{id: device1, model: m}
|
||||
m.AddConnection(fc, protocol.Hello{})
|
||||
m.ClusterConfig(device1, protocol.ClusterConfig{
|
||||
Folders: []protocol.Folder{
|
||||
{
|
||||
ID: "default",
|
||||
Devices: []protocol.Device{
|
||||
{
|
||||
ID: myID,
|
||||
EncryptionPasswordToken: encToken,
|
||||
},
|
||||
{ID: device1},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
indexChan := make(chan []protocol.FileInfo, 1)
|
||||
done := make(chan struct{})
|
||||
defer close(done)
|
||||
fc.mut.Lock()
|
||||
fc.indexFn = func(_ context.Context, _ string, fs []protocol.FileInfo) {
|
||||
select {
|
||||
case indexChan <- fs:
|
||||
case <-done:
|
||||
}
|
||||
}
|
||||
fc.mut.Unlock()
|
||||
|
||||
files := genFiles(2)
|
||||
files[1].LocalFlags = protocol.FlagLocalReceiveOnly
|
||||
m.fmut.RLock()
|
||||
fset := m.folderFiles[fcfg.ID]
|
||||
m.fmut.RUnlock()
|
||||
fset.Update(protocol.LocalDeviceID, files)
|
||||
|
||||
select {
|
||||
case fs := <-indexChan:
|
||||
if len(fs) != 1 {
|
||||
t.Error("Expected index with one file, got", fs)
|
||||
}
|
||||
if got := fs[0].Name; got != files[0].Name {
|
||||
t.Errorf("Expected file %v, got %v", got, files[0].Name)
|
||||
}
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("timed out before receiving index")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user