Show 100% complete status for nodes without any files to sync (fixes #453)

This commit is contained in:
Jakob Borg 2014-08-05 20:16:25 +02:00
parent b2c196e5c7
commit 62d703f967
3 changed files with 23 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@ -168,6 +168,9 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
OutBytesTotal: 0,
Address: arg.data.addr,
};
$scope.completion[arg.data.id] = {
_total: 100,
};
}
});
@ -284,6 +287,11 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
$scope.config.Options.ListenStr = $scope.config.Options.ListenAddress.join(', ');
$scope.nodes = $scope.config.Nodes;
$scope.nodes.forEach(function (nodeCfg) {
$scope.completion[nodeCfg.NodeID] = {
_total: 100,
};
});
$scope.nodes.sort(nodeCompare);
$scope.repos = repoMap($scope.config.Repositories);

View File

@ -199,7 +199,15 @@ func (m *Model) ConnectionStats() map[string]ConnectionInfo {
// Returns the completion status, in percent, for the given node and repo.
func (m *Model) Completion(node protocol.NodeID, repo string) float64 {
var tot int64
m.repoFiles[repo].WithGlobal(func(f protocol.FileInfo) bool {
m.rmut.RLock()
rf, ok := m.repoFiles[repo]
m.rmut.RUnlock()
if !ok {
return 0 // Repo doesn't exist, so we hardly have any of it
}
rf.WithGlobal(func(f protocol.FileInfo) bool {
if !protocol.IsDeleted(f.Flags) {
var size int64
if protocol.IsDirectory(f.Flags) {
@ -212,8 +220,12 @@ func (m *Model) Completion(node protocol.NodeID, repo string) float64 {
return true
})
if tot == 0 {
return 100 // Repo is empty, so we have all of it
}
var need int64
m.repoFiles[repo].WithNeed(node, func(f protocol.FileInfo) bool {
rf.WithNeed(node, func(f protocol.FileInfo) bool {
if !protocol.IsDeleted(f.Flags) {
var size int64
if protocol.IsDirectory(f.Flags) {