2016-03-24 08:09:13 +00:00
|
|
|
// Copyright (C) 2016 The Syncthing Authors.
|
|
|
|
//
|
|
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
2017-02-09 06:52:18 +00:00
|
|
|
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
2016-03-24 08:09:13 +00:00
|
|
|
|
2019-03-26 19:53:58 +00:00
|
|
|
package api
|
2016-03-24 08:09:13 +00:00
|
|
|
|
|
|
|
import (
|
2020-11-17 12:19:04 +00:00
|
|
|
"context"
|
2019-02-26 08:09:25 +00:00
|
|
|
"net"
|
2016-03-24 08:09:13 +00:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/syncthing/syncthing/lib/db"
|
2016-04-15 10:59:41 +00:00
|
|
|
"github.com/syncthing/syncthing/lib/model"
|
2016-03-24 08:09:13 +00:00
|
|
|
"github.com/syncthing/syncthing/lib/protocol"
|
|
|
|
"github.com/syncthing/syncthing/lib/stats"
|
2020-06-23 08:47:15 +00:00
|
|
|
"github.com/syncthing/syncthing/lib/ur/contract"
|
2018-01-01 14:39:23 +00:00
|
|
|
"github.com/syncthing/syncthing/lib/versioner"
|
2016-03-24 08:09:13 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type mockedModel struct{}
|
|
|
|
|
|
|
|
func (m *mockedModel) GlobalDirectoryTree(folder, prefix string, levels int, dirsonly bool) map[string]interface{} {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2016-08-12 06:41:43 +00:00
|
|
|
func (m *mockedModel) Completion(device protocol.DeviceID, folder string) model.FolderCompletion {
|
|
|
|
return model.FolderCompletion{}
|
2016-03-24 08:09:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedModel) Override(folder string) {}
|
|
|
|
|
2018-07-12 08:15:57 +00:00
|
|
|
func (m *mockedModel) Revert(folder string) {}
|
|
|
|
|
2020-11-27 10:26:36 +00:00
|
|
|
func (m *mockedModel) NeedFolderFiles(folder string, page, perpage int) ([]db.FileInfoTruncated, []db.FileInfoTruncated, []db.FileInfoTruncated, error) {
|
|
|
|
return nil, nil, nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*mockedModel) RemoteNeedFolderFiles(folder string, device protocol.DeviceID, page, perpage int) ([]db.FileInfoTruncated, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*mockedModel) LocalChangedFolderFiles(folder string, page, perpage int) ([]db.FileInfoTruncated, error) {
|
|
|
|
return nil, nil
|
2017-12-15 20:01:56 +00:00
|
|
|
}
|
|
|
|
|
2020-01-21 17:23:08 +00:00
|
|
|
func (m *mockedModel) FolderProgressBytesCompleted(_ string) int64 {
|
|
|
|
return 0
|
2016-03-24 08:09:13 +00:00
|
|
|
}
|
|
|
|
|
2021-01-11 14:14:44 +00:00
|
|
|
func (m *mockedModel) NumConnections() int {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2016-03-24 08:09:13 +00:00
|
|
|
func (m *mockedModel) ConnectionStats() map[string]interface{} {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-01-11 14:14:44 +00:00
|
|
|
func (m *mockedModel) DeviceStatistics() (map[protocol.DeviceID]stats.DeviceStatistics, error) {
|
2019-11-30 12:03:24 +00:00
|
|
|
return nil, nil
|
2016-03-24 08:09:13 +00:00
|
|
|
}
|
|
|
|
|
2019-11-30 12:03:24 +00:00
|
|
|
func (m *mockedModel) FolderStatistics() (map[string]stats.FolderStatistics, error) {
|
|
|
|
return nil, nil
|
2016-03-24 08:09:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedModel) CurrentFolderFile(folder string, file string) (protocol.FileInfo, bool) {
|
|
|
|
return protocol.FileInfo{}, false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedModel) CurrentGlobalFile(folder string, file string) (protocol.FileInfo, bool) {
|
|
|
|
return protocol.FileInfo{}, false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedModel) ResetFolder(folder string) {
|
|
|
|
}
|
|
|
|
|
2018-04-16 18:08:50 +00:00
|
|
|
func (m *mockedModel) Availability(folder string, file protocol.FileInfo, block protocol.BlockInfo) []model.Availability {
|
2016-03-24 08:09:13 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedModel) GetIgnores(folder string) ([]string, []string, error) {
|
|
|
|
return nil, nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedModel) SetIgnores(folder string, content []string) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-01-01 14:39:23 +00:00
|
|
|
func (m *mockedModel) GetFolderVersions(folder string) (map[string][]versioner.FileVersion, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedModel) RestoreFolderVersions(folder string, versions map[string]time.Time) (map[string]string, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2016-03-24 08:09:13 +00:00
|
|
|
func (m *mockedModel) PauseDevice(device protocol.DeviceID) {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedModel) ResumeDevice(device protocol.DeviceID) {}
|
|
|
|
|
|
|
|
func (m *mockedModel) DelayScan(folder string, next time.Duration) {}
|
|
|
|
|
|
|
|
func (m *mockedModel) ScanFolder(folder string) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedModel) ScanFolders() map[string]error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2016-06-29 06:37:34 +00:00
|
|
|
func (m *mockedModel) ScanFolderSubdirs(folder string, subs []string) error {
|
2016-03-24 08:09:13 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedModel) BringToFront(folder, file string) {}
|
|
|
|
|
2020-12-21 10:40:51 +00:00
|
|
|
func (m *mockedModel) Connection(deviceID protocol.DeviceID) (protocol.Connection, bool) {
|
2017-11-21 07:25:38 +00:00
|
|
|
return nil, false
|
2016-03-24 08:09:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedModel) State(folder string) (string, time.Time, error) {
|
|
|
|
return "", time.Time{}, nil
|
|
|
|
}
|
2017-10-12 06:16:46 +00:00
|
|
|
|
2020-06-23 08:47:15 +00:00
|
|
|
func (m *mockedModel) UsageReportingStats(r *contract.Report, version int, preview bool) {
|
2017-10-12 06:16:46 +00:00
|
|
|
}
|
2018-01-14 17:01:06 +00:00
|
|
|
|
2020-12-17 18:54:31 +00:00
|
|
|
func (m *mockedModel) PendingDevices() (map[protocol.DeviceID]db.ObservedDevice, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedModel) PendingFolders(device protocol.DeviceID) (map[string]db.PendingFolder, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2018-11-07 10:04:41 +00:00
|
|
|
func (m *mockedModel) FolderErrors(folder string) ([]model.FileError, error) {
|
2018-01-14 17:01:06 +00:00
|
|
|
return nil, nil
|
|
|
|
}
|
2018-02-04 21:46:24 +00:00
|
|
|
|
|
|
|
func (m *mockedModel) WatchError(folder string) error {
|
|
|
|
return nil
|
|
|
|
}
|
2018-12-11 08:59:04 +00:00
|
|
|
|
2020-11-17 12:19:04 +00:00
|
|
|
func (m *mockedModel) Serve(ctx context.Context) error { return nil }
|
2019-12-04 09:46:55 +00:00
|
|
|
|
|
|
|
func (m *mockedModel) Index(deviceID protocol.DeviceID, folder string, files []protocol.FileInfo) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedModel) IndexUpdate(deviceID protocol.DeviceID, folder string, files []protocol.FileInfo) error {
|
|
|
|
return nil
|
2019-02-26 08:09:25 +00:00
|
|
|
}
|
|
|
|
|
2020-11-09 14:33:32 +00:00
|
|
|
func (m *mockedModel) Request(deviceID protocol.DeviceID, folder, name string, blockNo, size int32, offset int64, hash []byte, weakHash uint32, fromTemporary bool) (protocol.RequestResponse, error) {
|
2019-02-26 08:09:25 +00:00
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2019-12-04 09:46:55 +00:00
|
|
|
func (m *mockedModel) ClusterConfig(deviceID protocol.DeviceID, config protocol.ClusterConfig) error {
|
|
|
|
return nil
|
|
|
|
}
|
2019-02-26 08:09:25 +00:00
|
|
|
|
|
|
|
func (m *mockedModel) Closed(conn protocol.Connection, err error) {}
|
|
|
|
|
2019-12-04 09:46:55 +00:00
|
|
|
func (m *mockedModel) DownloadProgress(deviceID protocol.DeviceID, folder string, updates []protocol.FileDownloadProgressUpdate) error {
|
|
|
|
return nil
|
2019-02-26 08:09:25 +00:00
|
|
|
}
|
|
|
|
|
2020-12-21 10:40:51 +00:00
|
|
|
func (m *mockedModel) AddConnection(conn protocol.Connection, hello protocol.Hello) {}
|
2019-02-26 08:09:25 +00:00
|
|
|
|
2020-09-29 11:17:38 +00:00
|
|
|
func (m *mockedModel) OnHello(protocol.DeviceID, net.Addr, protocol.Hello) error {
|
2019-02-26 08:09:25 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedModel) GetHello(protocol.DeviceID) protocol.HelloIntf {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedModel) StartDeadlockDetector(timeout time.Duration) {}
|
2020-01-21 17:23:08 +00:00
|
|
|
|
|
|
|
func (m *mockedModel) DBSnapshot(_ string) (*db.Snapshot, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type mockedFolderSummaryService struct{}
|
|
|
|
|
2020-11-17 12:19:04 +00:00
|
|
|
func (m *mockedFolderSummaryService) Serve(context.Context) error { return nil }
|
2020-01-21 17:23:08 +00:00
|
|
|
|
|
|
|
func (m *mockedFolderSummaryService) Summary(folder string) (map[string]interface{}, error) {
|
|
|
|
return map[string]interface{}{"mocked": true}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockedFolderSummaryService) OnEventRequest() {}
|