Forráskód Böngészése

cmd/syncthing: Emit new RemoteDownloadProgress event to track remote download progress

Without this the summary service doesn't know to recalculate completion
percentage for remote devices when DownloadProgress messages come in.
That means that completion percentage isn't updated in the GUI while
transfers of large files are ongoing. With this change, it updates
correctly.

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3144
Jakob Borg 9 éve
szülő
commit
a0ec4467fd
3 módosított fájl, 11 hozzáadás és 1 törlés
  1. 1 1
      cmd/syncthing/summaryservice.go
  2. 3 0
      lib/events/events.go
  3. 7 0
      lib/model/model.go

+ 1 - 1
cmd/syncthing/summaryservice.go

@@ -59,7 +59,7 @@ func (c *folderSummaryService) Stop() {
 // listenForUpdates subscribes to the event bus and makes note of folders that
 // listenForUpdates subscribes to the event bus and makes note of folders that
 // need their data recalculated.
 // need their data recalculated.
 func (c *folderSummaryService) listenForUpdates() {
 func (c *folderSummaryService) listenForUpdates() {
-	sub := events.Default.Subscribe(events.LocalIndexUpdated | events.RemoteIndexUpdated | events.StateChanged)
+	sub := events.Default.Subscribe(events.LocalIndexUpdated | events.RemoteIndexUpdated | events.StateChanged | events.RemoteDownloadProgress)
 	defer events.Default.Unsubscribe(sub)
 	defer events.Default.Unsubscribe(sub)
 
 
 	for {
 	for {

+ 3 - 0
lib/events/events.go

@@ -36,6 +36,7 @@ const (
 	FolderRejected
 	FolderRejected
 	ConfigSaved
 	ConfigSaved
 	DownloadProgress
 	DownloadProgress
+	RemoteDownloadProgress
 	FolderSummary
 	FolderSummary
 	FolderCompletion
 	FolderCompletion
 	FolderErrors
 	FolderErrors
@@ -80,6 +81,8 @@ func (t EventType) String() string {
 		return "ConfigSaved"
 		return "ConfigSaved"
 	case DownloadProgress:
 	case DownloadProgress:
 		return "DownloadProgress"
 		return "DownloadProgress"
+	case RemoteDownloadProgress:
+		return "RemoteDownloadProgress"
 	case FolderSummary:
 	case FolderSummary:
 		return "FolderSummary"
 		return "FolderSummary"
 	case FolderCompletion:
 	case FolderCompletion:

+ 7 - 0
lib/model/model.go

@@ -1083,7 +1083,14 @@ func (m *Model) DownloadProgress(device protocol.DeviceID, folder string, update
 
 
 	m.pmut.RLock()
 	m.pmut.RLock()
 	m.deviceDownloads[device].Update(folder, updates)
 	m.deviceDownloads[device].Update(folder, updates)
+	blocks := m.deviceDownloads[device].NumberOfBlocksInProgress()
 	m.pmut.RUnlock()
 	m.pmut.RUnlock()
+
+	events.Default.Log(events.RemoteDownloadProgress, map[string]interface{}{
+		"device": device.String(),
+		"folder": folder,
+		"blocks": blocks,
+	})
 }
 }
 
 
 func (m *Model) ResumeDevice(device protocol.DeviceID) {
 func (m *Model) ResumeDevice(device protocol.DeviceID) {