mirror of
https://github.com/syncthing/syncthing.git
synced 2024-11-16 02:18:44 -07:00
lib/model: Create folders via newFolder
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4329
This commit is contained in:
parent
c7221b035d
commit
ddf6d64faa
@ -9,10 +9,13 @@ package model
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/syncthing/syncthing/lib/config"
|
||||
)
|
||||
|
||||
type folder struct {
|
||||
stateTracker
|
||||
config.FolderConfiguration
|
||||
|
||||
scan folderScanner
|
||||
model *Model
|
||||
@ -21,9 +24,23 @@ type folder struct {
|
||||
initialScanFinished chan struct{}
|
||||
}
|
||||
|
||||
func (f *folder) IndexUpdated() {
|
||||
func newFolder(model *Model, cfg config.FolderConfiguration) folder {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
return folder{
|
||||
stateTracker: newStateTracker(cfg.ID),
|
||||
FolderConfiguration: cfg,
|
||||
|
||||
scan: newFolderScanner(cfg),
|
||||
ctx: ctx,
|
||||
cancel: cancel,
|
||||
model: model,
|
||||
initialScanFinished: make(chan struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
func (f *folder) IndexUpdated() {
|
||||
}
|
||||
func (f *folder) DelayScan(next time.Duration) {
|
||||
f.scan.Delay(next)
|
||||
}
|
||||
|
@ -7,7 +7,6 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/syncthing/syncthing/lib/config"
|
||||
@ -21,23 +20,10 @@ func init() {
|
||||
|
||||
type sendOnlyFolder struct {
|
||||
folder
|
||||
config.FolderConfiguration
|
||||
}
|
||||
|
||||
func newSendOnlyFolder(model *Model, cfg config.FolderConfiguration, _ versioner.Versioner, _ fs.Filesystem) service {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
return &sendOnlyFolder{
|
||||
folder: folder{
|
||||
stateTracker: newStateTracker(cfg.ID),
|
||||
scan: newFolderScanner(cfg),
|
||||
ctx: ctx,
|
||||
cancel: cancel,
|
||||
model: model,
|
||||
initialScanFinished: make(chan struct{}),
|
||||
},
|
||||
FolderConfiguration: cfg,
|
||||
}
|
||||
return &sendOnlyFolder{folder: newFolder(model, cfg)}
|
||||
}
|
||||
|
||||
func (f *sendOnlyFolder) Serve() {
|
||||
|
@ -7,7 +7,6 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
@ -81,7 +80,6 @@ type dbUpdateJob struct {
|
||||
|
||||
type sendReceiveFolder struct {
|
||||
folder
|
||||
config.FolderConfiguration
|
||||
|
||||
fs fs.Filesystem
|
||||
versioner versioner.Versioner
|
||||
@ -98,18 +96,8 @@ type sendReceiveFolder struct {
|
||||
}
|
||||
|
||||
func newSendReceiveFolder(model *Model, cfg config.FolderConfiguration, ver versioner.Versioner, fs fs.Filesystem) service {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
f := &sendReceiveFolder{
|
||||
folder: folder{
|
||||
stateTracker: newStateTracker(cfg.ID),
|
||||
scan: newFolderScanner(cfg),
|
||||
ctx: ctx,
|
||||
cancel: cancel,
|
||||
model: model,
|
||||
initialScanFinished: make(chan struct{}),
|
||||
},
|
||||
FolderConfiguration: cfg,
|
||||
folder: newFolder(model, cfg),
|
||||
|
||||
fs: fs,
|
||||
versioner: ver,
|
||||
|
Loading…
Reference in New Issue
Block a user