Run go fmt -w
This commit is contained in:
@@ -69,29 +69,29 @@ type Model struct {
|
||||
cfg *config.Configuration
|
||||
db *leveldb.DB
|
||||
|
||||
deviceName string
|
||||
deviceName string
|
||||
clientName string
|
||||
clientVersion string
|
||||
|
||||
folderCfgs map[string]config.FolderConfiguration // folder -> cfg
|
||||
folderFiles map[string]*files.Set // folder -> files
|
||||
folderDevices map[string][]protocol.DeviceID // folder -> deviceIDs
|
||||
deviceFolders map[protocol.DeviceID][]string // deviceID -> folders
|
||||
folderCfgs map[string]config.FolderConfiguration // folder -> cfg
|
||||
folderFiles map[string]*files.Set // folder -> files
|
||||
folderDevices map[string][]protocol.DeviceID // folder -> deviceIDs
|
||||
deviceFolders map[protocol.DeviceID][]string // deviceID -> folders
|
||||
deviceStatRefs map[protocol.DeviceID]*stats.DeviceStatisticsReference // deviceID -> statsRef
|
||||
folderIgnores map[string]ignore.Patterns // folder -> list of ignore patterns
|
||||
rmut sync.RWMutex // protects the above
|
||||
folderIgnores map[string]ignore.Patterns // folder -> list of ignore patterns
|
||||
rmut sync.RWMutex // protects the above
|
||||
|
||||
folderState map[string]folderState // folder -> state
|
||||
folderStateChanged map[string]time.Time // folder -> time when state changed
|
||||
smut sync.RWMutex
|
||||
folderStateChanged map[string]time.Time // folder -> time when state changed
|
||||
smut sync.RWMutex
|
||||
|
||||
protoConn map[protocol.DeviceID]protocol.Connection
|
||||
rawConn map[protocol.DeviceID]io.Closer
|
||||
deviceVer map[protocol.DeviceID]string
|
||||
deviceVer map[protocol.DeviceID]string
|
||||
pmut sync.RWMutex // protects protoConn and rawConn
|
||||
|
||||
addedFolder bool
|
||||
started bool
|
||||
started bool
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -104,22 +104,22 @@ var (
|
||||
// for file data without altering the local folder in any way.
|
||||
func NewModel(indexDir string, cfg *config.Configuration, deviceName, clientName, clientVersion string, db *leveldb.DB) *Model {
|
||||
m := &Model{
|
||||
indexDir: indexDir,
|
||||
cfg: cfg,
|
||||
db: db,
|
||||
indexDir: indexDir,
|
||||
cfg: cfg,
|
||||
db: db,
|
||||
deviceName: deviceName,
|
||||
clientName: clientName,
|
||||
clientVersion: clientVersion,
|
||||
clientName: clientName,
|
||||
clientVersion: clientVersion,
|
||||
folderCfgs: make(map[string]config.FolderConfiguration),
|
||||
folderFiles: make(map[string]*files.Set),
|
||||
folderDevices: make(map[string][]protocol.DeviceID),
|
||||
deviceFolders: make(map[protocol.DeviceID][]string),
|
||||
folderDevices: make(map[string][]protocol.DeviceID),
|
||||
deviceFolders: make(map[protocol.DeviceID][]string),
|
||||
deviceStatRefs: make(map[protocol.DeviceID]*stats.DeviceStatisticsReference),
|
||||
folderIgnores: make(map[string]ignore.Patterns),
|
||||
folderState: make(map[string]folderState),
|
||||
folderStateChanged: make(map[string]time.Time),
|
||||
protoConn: make(map[protocol.DeviceID]protocol.Connection),
|
||||
rawConn: make(map[protocol.DeviceID]io.Closer),
|
||||
protoConn: make(map[protocol.DeviceID]protocol.Connection),
|
||||
rawConn: make(map[protocol.DeviceID]io.Closer),
|
||||
deviceVer: make(map[protocol.DeviceID]string),
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ func (m *Model) StartFolderRW(folder string) {
|
||||
}
|
||||
|
||||
p := Puller{
|
||||
folder: folder,
|
||||
folder: folder,
|
||||
dir: cfg.Directory,
|
||||
scanIntv: time.Duration(cfg.RescanIntervalS) * time.Second,
|
||||
model: m,
|
||||
@@ -411,8 +411,8 @@ func (m *Model) Index(deviceID protocol.DeviceID, folder string, fs []protocol.F
|
||||
files.Replace(deviceID, fs)
|
||||
|
||||
events.Default.Log(events.RemoteIndexUpdated, map[string]interface{}{
|
||||
"device": deviceID.String(),
|
||||
"folder": folder,
|
||||
"device": deviceID.String(),
|
||||
"folder": folder,
|
||||
"items": len(fs),
|
||||
"version": files.LocalVersion(deviceID),
|
||||
})
|
||||
@@ -452,8 +452,8 @@ func (m *Model) IndexUpdate(deviceID protocol.DeviceID, folder string, fs []prot
|
||||
files.Update(deviceID, fs)
|
||||
|
||||
events.Default.Log(events.RemoteIndexUpdated, map[string]interface{}{
|
||||
"device": deviceID.String(),
|
||||
"folder": folder,
|
||||
"device": deviceID.String(),
|
||||
"folder": folder,
|
||||
"items": len(fs),
|
||||
"version": files.LocalVersion(deviceID),
|
||||
})
|
||||
@@ -890,7 +890,7 @@ func (m *Model) updateLocal(folder string, f protocol.FileInfo) {
|
||||
m.folderFiles[folder].Update(protocol.LocalDeviceID, []protocol.FileInfo{f})
|
||||
m.rmut.RUnlock()
|
||||
events.Default.Log(events.LocalIndexUpdated, map[string]interface{}{
|
||||
"folder": folder,
|
||||
"folder": folder,
|
||||
"name": f.Name,
|
||||
"modified": time.Unix(f.Modified, 0),
|
||||
"flags": fmt.Sprintf("0%o", f.Flags),
|
||||
@@ -1022,7 +1022,7 @@ func (m *Model) ScanFolderSub(folder, sub string) error {
|
||||
batch := make([]protocol.FileInfo, 0, 00)
|
||||
for f := range fchan {
|
||||
events.Default.Log(events.LocalIndexUpdated, map[string]interface{}{
|
||||
"folder": folder,
|
||||
"folder": folder,
|
||||
"name": f.Name,
|
||||
"modified": time.Unix(f.Modified, 0),
|
||||
"flags": fmt.Sprintf("0%o", f.Flags),
|
||||
@@ -1070,7 +1070,7 @@ func (m *Model) ScanFolderSub(folder, sub string) error {
|
||||
Version: f.Version, // The file is still the same, so don't bump version
|
||||
}
|
||||
events.Default.Log(events.LocalIndexUpdated, map[string]interface{}{
|
||||
"folder": folder,
|
||||
"folder": folder,
|
||||
"name": f.Name,
|
||||
"modified": time.Unix(f.Modified, 0),
|
||||
"flags": fmt.Sprintf("0%o", f.Flags),
|
||||
@@ -1086,7 +1086,7 @@ func (m *Model) ScanFolderSub(folder, sub string) error {
|
||||
Version: lamport.Default.Tick(f.Version),
|
||||
}
|
||||
events.Default.Log(events.LocalIndexUpdated, map[string]interface{}{
|
||||
"folder": folder,
|
||||
"folder": folder,
|
||||
"name": f.Name,
|
||||
"modified": time.Unix(f.Modified, 0),
|
||||
"flags": fmt.Sprintf("0%o", f.Flags),
|
||||
@@ -1153,7 +1153,7 @@ func (m *Model) setState(folder string, state folderState) {
|
||||
m.folderStateChanged[folder] = time.Now()
|
||||
eventData := map[string]interface{}{
|
||||
"folder": folder,
|
||||
"to": state.String(),
|
||||
"to": state.String(),
|
||||
}
|
||||
if ok {
|
||||
eventData["duration"] = time.Since(changed).Seconds()
|
||||
|
||||
@@ -287,7 +287,7 @@ func TestClusterConfig(t *testing.T) {
|
||||
cfg := config.New("/tmp/test", device1)
|
||||
cfg.Devices = []config.DeviceConfiguration{
|
||||
{
|
||||
DeviceID: device1,
|
||||
DeviceID: device1,
|
||||
Introducer: true,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -26,9 +26,9 @@ const (
|
||||
copiersPerFolder = 1
|
||||
pullersPerFolder = 16
|
||||
finishersPerFolder = 2
|
||||
pauseIntv = 60 * time.Second
|
||||
nextPullIntv = 10 * time.Second
|
||||
checkPullIntv = 1 * time.Second
|
||||
pauseIntv = 60 * time.Second
|
||||
nextPullIntv = 10 * time.Second
|
||||
checkPullIntv = 1 * time.Second
|
||||
)
|
||||
|
||||
// A pullBlockState is passed to the puller routine for each block that needs
|
||||
@@ -46,12 +46,12 @@ type copyBlocksState struct {
|
||||
}
|
||||
|
||||
var (
|
||||
activity = newDeviceActivity()
|
||||
activity = newDeviceActivity()
|
||||
errNoDevice = errors.New("no available source device")
|
||||
)
|
||||
|
||||
type Puller struct {
|
||||
folder string
|
||||
folder string
|
||||
dir string
|
||||
scanIntv time.Duration
|
||||
model *Model
|
||||
@@ -129,7 +129,7 @@ loop:
|
||||
// version that includes those files in curVer. So we
|
||||
// catch the case that localVersion might have
|
||||
// decresed here.
|
||||
l.Debugln(p,"adjusting curVer",lv)
|
||||
l.Debugln(p, "adjusting curVer", lv)
|
||||
curVer = lv
|
||||
}
|
||||
prevVer = curVer
|
||||
@@ -241,7 +241,7 @@ func (p *Puller) pullerIteration(ncopiers, npullers, nfinishers int) int {
|
||||
|
||||
events.Default.Log(events.ItemStarted, map[string]string{
|
||||
"folder": p.folder,
|
||||
"item": file.Name,
|
||||
"item": file.Name,
|
||||
})
|
||||
|
||||
if debug {
|
||||
@@ -384,7 +384,7 @@ func (p *Puller) handleFile(file protocol.FileInfo, copyChan chan<- copyBlocksSt
|
||||
|
||||
s := sharedPullerState{
|
||||
file: file,
|
||||
folder: p.folder,
|
||||
folder: p.folder,
|
||||
tempName: tempName,
|
||||
realName: realName,
|
||||
pullNeeded: len(pullBlocks),
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
type sharedPullerState struct {
|
||||
// Immutable, does not require locking
|
||||
file protocol.FileInfo
|
||||
folder string
|
||||
folder string
|
||||
tempName string
|
||||
realName string
|
||||
|
||||
|
||||
Reference in New Issue
Block a user