Skip to content

Commit

Permalink
fix counting
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleduo committed May 22, 2017
1 parent a606ae2 commit 1e85db5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/tinypng4mac/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class MainViewController: NSViewController, NSOpenSavePanelDelegate, NSTableView
}
totalSize += task.originSize
totalRecudeSize += (task.originSize - task.resultSize)
totalReduce.stringValue = String.localizedStringWithFormat(NSLocalizedString("tasks desc", comment: "tasks desc"), TPStore.sharedStore.count(), Formator.formatSize(totalRecudeSize), Formator.formatRate(totalRecudeSize / totalSize))
totalReduce.stringValue = String.localizedStringWithFormat(NSLocalizedString("tasks desc", comment: "tasks desc"), TPClient.sharedClient.finishTasksCount, Formator.formatSize(totalRecudeSize), Formator.formatRate(totalRecudeSize / totalSize))

if TPClient.sharedClient.queue.isEmpty() {
// all finished
Expand Down
4 changes: 4 additions & 0 deletions source/tinypng4mac/tpclient/TPClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class TPClient {
let queue = TPQueue()
let lock: NSLock = NSLock()
var runningTasks = 0
var finishTasksCount = 0

func add(_ tasks: [TPTaskInfo]) {
TPStore.sharedStore.add(tasks);
Expand Down Expand Up @@ -162,6 +163,9 @@ class TPClient {
task.progress = progress
if newStatus == .error || newStatus == .finish {
self.runningTasks -= 1
if newStatus == .finish {
self.finishTasksCount += 1
}
}
callback.taskStatusChanged(task: task)
}
Expand Down

0 comments on commit 1e85db5

Please sign in to comment.