mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-10 07:11:08 +00:00
fd0a147ae6
Request to terminate currently ongoing downloads and jump to the bumped file incoming in 3, 2, 1. Also, has a slightly strange effect where we pop a job off the queue, but the copyChannel is still busy and blocks, though it gets moved to the progress slice in the jobqueue, and looks like it's in progress which it isn't as it's waiting to be picked up from the copyChan. As a result, the progress emitter doesn't register on the task, and hence the file doesn't have a progress bar, but cannot be replaced by a bump. I guess I can fix progress bar issue by moving the progressEmiter.Register just before passing the file to the copyChan, but then we are back to the initial problem of a file with a progress bar, but no progress happening as it's stuck on write to copyChan I checked if there is a way to check for channel writeability (before popping) but got struck by lightning just for bringing the idea up in #go-nuts. My ideal scenario would be to check if copyChan is writeable, pop job from the queue and shove it down handleFile. This way jobs would stay in the queue while they cannot be handled, meaning that the `Bump` could bring your file up higher.
86 lines
1.8 KiB
Go
86 lines
1.8 KiB
Go
// Copyright (C) 2014 The Syncthing Authors.
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify it
|
|
// under the terms of the GNU General Public License as published by the Free
|
|
// Software Foundation, either version 3 of the License, or (at your option)
|
|
// any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
// more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License along
|
|
// with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
package model
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/syncthing/syncthing/internal/protocol"
|
|
)
|
|
|
|
type Scanner struct {
|
|
folder string
|
|
intv time.Duration
|
|
model *Model
|
|
stop chan struct{}
|
|
}
|
|
|
|
func (s *Scanner) Serve() {
|
|
if debug {
|
|
l.Debugln(s, "starting")
|
|
defer l.Debugln(s, "exiting")
|
|
}
|
|
|
|
timer := time.NewTimer(time.Millisecond)
|
|
defer timer.Stop()
|
|
|
|
initialScanCompleted := false
|
|
for {
|
|
select {
|
|
case <-s.stop:
|
|
return
|
|
|
|
case <-timer.C:
|
|
if debug {
|
|
l.Debugln(s, "rescan")
|
|
}
|
|
|
|
s.model.setState(s.folder, FolderScanning)
|
|
if err := s.model.ScanFolder(s.folder); err != nil {
|
|
s.model.cfg.InvalidateFolder(s.folder, err.Error())
|
|
return
|
|
}
|
|
s.model.setState(s.folder, FolderIdle)
|
|
|
|
if !initialScanCompleted {
|
|
l.Infoln("Completed initial scan (ro) of folder", s.folder)
|
|
initialScanCompleted = true
|
|
}
|
|
|
|
if s.intv == 0 {
|
|
return
|
|
}
|
|
|
|
timer.Reset(s.intv)
|
|
}
|
|
}
|
|
}
|
|
|
|
func (s *Scanner) Stop() {
|
|
close(s.stop)
|
|
}
|
|
|
|
func (s *Scanner) String() string {
|
|
return fmt.Sprintf("scanner/%s@%p", s.folder, s)
|
|
}
|
|
|
|
func (s *Scanner) Bump(string) {}
|
|
|
|
func (s *Scanner) Jobs() ([]protocol.FileInfoTruncated, []protocol.FileInfoTruncated) {
|
|
return nil, nil
|
|
}
|