mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-08 22:31:04 +00:00
Change progress emitter
1. Do not use cached value for BytesCompleted 2. Refactor JS a bit 3. Allow disabling progress emitter
This commit is contained in:
parent
c7d779fe88
commit
ea17542e4b
33
gui/app.js
33
gui/app.js
@ -301,20 +301,19 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
|
||||
}
|
||||
}
|
||||
for(var folder in $scope.progress){
|
||||
var refresh = false;
|
||||
if (!(folder in progress)) {
|
||||
refresh = true;
|
||||
refreshFolder(folder);
|
||||
} else {
|
||||
if ($scope.neededFolder == folder) {
|
||||
refreshNeed(folder);
|
||||
}
|
||||
} else if ($scope.neededFolder == folder) {
|
||||
for(file in $scope.progress[folder]){
|
||||
if (!(file in progress[folder])) {
|
||||
refresh = true;
|
||||
refreshNeed(folder);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (refresh) {
|
||||
refreshNeed(folder);
|
||||
}
|
||||
}
|
||||
$scope.progress = progress;
|
||||
console.log("DownloadProgress", $scope.progress);
|
||||
@ -444,15 +443,13 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
|
||||
});
|
||||
}
|
||||
|
||||
function refreshNeed (folder) {
|
||||
if ($scope.neededFolder == folder) {
|
||||
$http.get(urlbase + "/need?folder=" + encodeURIComponent(folder)).success(function (data) {
|
||||
if ($scope.neededFolder == folder) {
|
||||
console.log("refreshNeed", folder, data);
|
||||
$scope.needed = data;
|
||||
}
|
||||
});
|
||||
}
|
||||
function refreshNeed(folder) {
|
||||
$http.get(urlbase + "/need?folder=" + encodeURIComponent(folder)).success(function (data) {
|
||||
if ($scope.neededFolder == folder) {
|
||||
console.log("refreshNeed", folder, data);
|
||||
$scope.needed = data;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var refreshDeviceStats = debounce(function () {
|
||||
@ -536,7 +533,7 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
|
||||
}
|
||||
|
||||
var pct = 100 * $scope.model[folder].inSyncBytes / $scope.model[folder].globalBytes;
|
||||
return Math.min(Math.floor(pct), 100);
|
||||
return Math.floor(pct);
|
||||
};
|
||||
|
||||
$scope.deviceIcon = function (deviceCfg) {
|
||||
@ -1037,7 +1034,7 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
|
||||
$scope.showNeed = function (folder) {
|
||||
$scope.neededFolder = folder;
|
||||
refreshNeed(folder);
|
||||
$('#needed').modal().result.finally(function(){
|
||||
$('#needed').modal().on('hidden.bs.modal', function(){
|
||||
$scope.neededFolder = undefined;
|
||||
$scope.needed = undefined;
|
||||
});
|
||||
|
File diff suppressed because one or more lines are too long
@ -145,7 +145,9 @@ func NewModel(cfg *config.ConfigWrapper, deviceName, clientName, clientVersion s
|
||||
finder: files.NewBlockFinder(db, cfg),
|
||||
progressEmitter: NewProgressEmitter(cfg),
|
||||
}
|
||||
go m.progressEmitter.Serve()
|
||||
if cfg.Options().ProgressUpdateIntervalS > -1 {
|
||||
go m.progressEmitter.Serve()
|
||||
}
|
||||
|
||||
var timeout = 20 * 60 // seconds
|
||||
if t := os.Getenv("STDEADLOCKTIMEOUT"); len(t) > 0 {
|
||||
|
@ -120,10 +120,9 @@ func (t *ProgressEmitter) BytesCompleted(folder string) (bytes int64) {
|
||||
t.mut.Lock()
|
||||
defer t.mut.Unlock()
|
||||
|
||||
files, ok := t.last[folder]
|
||||
if ok {
|
||||
for _, s := range files {
|
||||
bytes += s.BytesDone
|
||||
for _, s := range t.registry {
|
||||
if s.folder == folder {
|
||||
bytes += s.Progress().BytesDone
|
||||
}
|
||||
}
|
||||
if debug {
|
||||
|
Loading…
Reference in New Issue
Block a user