Skip to content
This repository was archived by the owner on Oct 8, 2024. It is now read-only.

Commit a13f87b

Browse files
committed
update
1 parent d646641 commit a13f87b

File tree

7 files changed

+75
-97
lines changed

7 files changed

+75
-97
lines changed

RsyncOSX/Configurations.swift

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Configurations: ReloadTable, SetSchedules {
2525
// backup list from remote info view
2626
// var quickbackuplist: [Int]?
2727
// Estimated backup list, all backups
28-
var estimatedlist: [NSMutableDictionary]?
28+
// var estimatedlist: [NSMutableDictionary]?
2929
// remote and local info
3030
var localremote: [NSDictionary]?
3131
// remote info tasks
@@ -57,14 +57,15 @@ class Configurations: ReloadTable, SetSchedules {
5757
return 0
5858
}
5959

60-
func setestimatedlistnil() -> Bool {
61-
if (self.estimatedlist?.count ?? 0) == (self.configurations?.count ?? 0) {
62-
return false
63-
} else {
64-
return true
65-
}
66-
}
67-
60+
/*
61+
func setestimatedlistnil() -> Bool {
62+
if (self.estimatedlist?.count ?? 0) == (self.configurations?.count ?? 0) {
63+
return false
64+
} else {
65+
return true
66+
}
67+
}
68+
*/
6869
// Function for getting the profile
6970
func getProfile() -> String? {
7071
return self.profile

RsyncOSX/ConfigurationsAsDictionarys.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Foundation
1010

1111
struct ConfigurationsAsDictionarys: SetConfigurations {
1212
var quickbackuplist: [Int]?
13+
var estimatedlist: [NSMutableDictionary]?
1314

1415
// Function for getting all Configurations
1516
func getConfigurationsDataSourceSynchronize() -> [NSMutableDictionary]? {
@@ -37,9 +38,12 @@ struct ConfigurationsAsDictionarys: SetConfigurations {
3738
return data
3839
}
3940

40-
init() {}
41+
init() {
42+
self.estimatedlist = [NSMutableDictionary]()
43+
}
4144

42-
init(quickbackuplist: [Int]?) {
45+
init(quickbackuplist: [Int]?, estimatedlist: [NSMutableDictionary]?) {
46+
self.estimatedlist = estimatedlist
4347
self.quickbackuplist = quickbackuplist
4448
}
4549
}

RsyncOSX/QuickBackup.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ final class QuickBackup: SetConfigurations {
8989
}
9090

9191
init() {
92-
self.estimatedlist = self.configurations?.estimatedlist
92+
// self.estimatedlist = self.configurations?.estimatedlist
9393
if self.estimatedlist != nil {
9494
self.sortedlist = ConfigurationsAsDictionarys().getConfigurationsDataSourceSynchronize()?.filter { ($0.value(forKey: DictionaryStrings.selectCellID.rawValue) as? Int) == 1 }
9595
guard self.sortedlist!.count > 0 else { return }

RsyncOSX/RemoteinfoEstimation.swift

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ final class RemoteinfoEstimation: SetConfigurations {
2121
var stackoftasktobeestimated: [Row]?
2222
var outputprocess: OutputProcess?
2323
var records: [NSMutableDictionary]?
24-
// weak var updateprogressDelegate: UpdateProgress?
2524
var updateviewprocesstermination: () -> Void
2625
weak var startstopProgressIndicatorDelegate: StartStopProgressIndicator?
2726
weak var getmultipleselectedindexesDelegate: GetMultipleSelectedIndexes?
2827
var index: Int?
2928
private var maxnumber: Int?
29+
// estimated list and other
30+
var estimatedlistandconfigs: ConfigurationsAsDictionarys?
3031

3132
private func prepareandstartexecutetasks() {
3233
self.stackoftasktobeestimated = [Row]()
@@ -66,44 +67,22 @@ final class RemoteinfoEstimation: SetConfigurations {
6667
}
6768
}
6869

69-
/*
70-
func setbackuplist(list: [NSMutableDictionary]) {
71-
self.configurations?.quickbackuplist = [Int]()
72-
for i in 0 ..< list.count {
73-
self.configurations?.quickbackuplist!.append((list[i].value(forKey: DictionaryStrings.hiddenID.rawValue) as? Int)!)
74-
}
75-
}
76-
77-
func setbackuplist() {
78-
guard self.records != nil else { return }
79-
self.configurations?.quickbackuplist = [Int]()
80-
for i in 0 ..< (self.records?.count ?? 0) {
81-
if self.records![i].value(forKey: DictionaryStrings.select.rawValue) as? Int == 1 {
82-
self.configurations?.quickbackuplist?.append((self.records![i].value(forKey: DictionaryStrings.hiddenID.rawValue) as? Int)!)
83-
}
84-
}
85-
}
86-
*/
87-
88-
func setbackuplist(list: [NSMutableDictionary]) {
89-
var quickbackuplist = [Int]()
90-
for i in 0 ..< list.count {
91-
if let hiddenID = list[i].value(forKey: DictionaryStrings.hiddenID.rawValue) as? Int {
92-
quickbackuplist.append(hiddenID)
93-
}
94-
}
95-
let test = ConfigurationsAsDictionarys(quickbackuplist: quickbackuplist)
96-
}
97-
98-
func setbackuplist() {
70+
private func setbackuplist() {
9971
guard self.records != nil else { return }
10072
var quickbackuplist = [Int]()
73+
var records = [NSMutableDictionary]()
10174
for i in 0 ..< (self.records?.count ?? 0) {
102-
if self.records![i].value(forKey: DictionaryStrings.select.rawValue) as? Int == 1 {
103-
quickbackuplist.append((self.records![i].value(forKey: DictionaryStrings.hiddenID.rawValue) as? Int)!)
75+
if self.records?[i].value(forKey: DictionaryStrings.select.rawValue) as? Int == 1 {
76+
if let hiddenID = self.records?[i].value(forKey: DictionaryStrings.hiddenID.rawValue) as? Int,
77+
let record = self.records?[i]
78+
{
79+
quickbackuplist.append(hiddenID)
80+
records.append(record)
81+
}
10482
}
10583
}
106-
let test = ConfigurationsAsDictionarys(quickbackuplist: quickbackuplist)
84+
self.estimatedlistandconfigs = ConfigurationsAsDictionarys(quickbackuplist: quickbackuplist,
85+
estimatedlist: records)
10786
}
10887

10988
private func startestimation() {
@@ -123,16 +102,19 @@ final class RemoteinfoEstimation: SetConfigurations {
123102
self.getmultipleselectedindexesDelegate = ViewControllerReference.shared.getvcref(viewcontroller: .vctabmain) as? ViewControllerMain
124103
self.prepareandstartexecutetasks()
125104
self.records = [NSMutableDictionary]()
126-
self.configurations?.estimatedlist = [NSMutableDictionary]()
105+
self.estimatedlistandconfigs = ConfigurationsAsDictionarys()
127106
self.startestimation()
128107
}
129108

130109
deinit {
131110
self.stackoftasktobeestimated = nil
111+
self.estimatedlistandconfigs = nil
112+
print("deinit RemoteinfoEstimation")
132113
}
133114

134115
func abort() {
135116
self.stackoftasktobeestimated = nil
117+
self.estimatedlistandconfigs = nil
136118
}
137119
}
138120

@@ -158,10 +140,9 @@ extension RemoteinfoEstimation {
158140
record.setValue(self.configurations?.getConfigurations()?[self.index!].offsiteServer, forKey: DictionaryStrings.offsiteServer.rawValue)
159141
}
160142
self.records?.append(record)
161-
self.configurations?.estimatedlist?.append(record)
143+
self.estimatedlistandconfigs?.estimatedlist?.append(record)
162144
guard self.stackoftasktobeestimated?.count ?? 0 > 0 else {
163145
self.selectalltaskswithnumbers(deselect: false)
164-
self.setbackuplist()
165146
self.startstopProgressIndicatorDelegate?.stop()
166147
return
167148
}

RsyncOSX/ViewControllerMain.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,7 @@ class ViewControllerMain: NSViewController, ReloadTable, Deselect, VcMain, Delay
6464
// Toolbar - Estimate and Quickbackup
6565
@IBAction func totinfo(_: NSButton) {
6666
guard self.checkforrsync() == false else { return }
67-
if self.configurations?.setestimatedlistnil() == true {
68-
self.configurations?.remoteinfoestimation = nil
69-
self.configurations?.estimatedlist = nil
70-
}
67+
self.configurations?.remoteinfoestimation = nil
7168
self.multipeselection = false
7269
globalMainQueue.async { () -> Void in
7370
self.presentAsSheet(self.viewControllerRemoteInfo!)
@@ -85,7 +82,6 @@ class ViewControllerMain: NSViewController, ReloadTable, Deselect, VcMain, Delay
8582
}
8683
self.multipeselection = true
8784
self.configurations?.remoteinfoestimation = nil
88-
self.configurations?.estimatedlist = nil
8985
globalMainQueue.async { () -> Void in
9086
self.presentAsSheet(self.viewControllerRemoteInfo!)
9187
}
@@ -241,7 +237,6 @@ class ViewControllerMain: NSViewController, ReloadTable, Deselect, VcMain, Delay
241237
super.viewDidDisappear()
242238
self.multipeselection = false
243239
self.configurations?.remoteinfoestimation = nil
244-
self.configurations?.estimatedlist = nil
245240
}
246241

247242
func reset() {

RsyncOSX/ViewControllerRemoteInfo.swift

Lines changed: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -21,45 +21,43 @@ class ViewControllerRemoteInfo: NSViewController, SetDismisser, Abort, Setcolor
2121
@IBOutlet var abortbutton: NSButton!
2222
@IBOutlet var count: NSTextField!
2323

24-
private var remoteinfotask: RemoteinfoEstimation?
24+
private var remoteestimatedlist: RemoteinfoEstimation?
2525
weak var remoteinfotaskDelegate: SetRemoteInfo?
2626
var loaded: Bool = false
2727
var diddissappear: Bool = false
2828

2929
@IBAction func execute(_: NSButton) {
30-
if let backup = self.dobackups() {
31-
if backup.count > 0 {
32-
self.remoteinfotask?.setbackuplist(list: backup)
33-
weak var openDelegate: OpenQuickBackup?
34-
if (self.presentingViewController as? ViewControllerMain) != nil {
35-
openDelegate = ViewControllerReference.shared.getvcref(viewcontroller: .vctabmain) as? ViewControllerMain
36-
} else if (self.presentingViewController as? ViewControllerSchedule) != nil {
37-
openDelegate = ViewControllerReference.shared.getvcref(viewcontroller: .vctabschedule) as? ViewControllerSchedule
38-
} else if (self.presentingViewController as? ViewControllerNewConfigurations) != nil {
39-
openDelegate = ViewControllerReference.shared.getvcref(viewcontroller: .vcnewconfigurations) as? ViewControllerNewConfigurations
40-
} else if (self.presentingViewController as? ViewControllerRestore) != nil {
41-
openDelegate = ViewControllerReference.shared.getvcref(viewcontroller: .vcrestore) as? ViewControllerRestore
42-
} else if (self.presentingViewController as? ViewControllerLoggData) != nil {
43-
openDelegate = ViewControllerReference.shared.getvcref(viewcontroller: .vcloggdata) as? ViewControllerLoggData
44-
} else if (self.presentingViewController as? ViewControllerSnapshots) != nil {
45-
openDelegate = ViewControllerReference.shared.getvcref(viewcontroller: .vcsnapshot) as? ViewControllerSnapshots
46-
}
47-
openDelegate?.openquickbackup()
30+
if (self.remoteestimatedlist?.estimatedlistandconfigs?.estimatedlist?.count ?? 0) > 0 {
31+
weak var openDelegate: OpenQuickBackup?
32+
if (self.presentingViewController as? ViewControllerMain) != nil {
33+
openDelegate = ViewControllerReference.shared.getvcref(viewcontroller: .vctabmain) as? ViewControllerMain
34+
} else if (self.presentingViewController as? ViewControllerSchedule) != nil {
35+
openDelegate = ViewControllerReference.shared.getvcref(viewcontroller: .vctabschedule) as? ViewControllerSchedule
36+
} else if (self.presentingViewController as? ViewControllerNewConfigurations) != nil {
37+
openDelegate = ViewControllerReference.shared.getvcref(viewcontroller: .vcnewconfigurations) as? ViewControllerNewConfigurations
38+
} else if (self.presentingViewController as? ViewControllerRestore) != nil {
39+
openDelegate = ViewControllerReference.shared.getvcref(viewcontroller: .vcrestore) as? ViewControllerRestore
40+
} else if (self.presentingViewController as? ViewControllerLoggData) != nil {
41+
openDelegate = ViewControllerReference.shared.getvcref(viewcontroller: .vcloggdata) as? ViewControllerLoggData
42+
} else if (self.presentingViewController as? ViewControllerSnapshots) != nil {
43+
openDelegate = ViewControllerReference.shared.getvcref(viewcontroller: .vcsnapshot) as? ViewControllerSnapshots
4844
}
45+
// openDelegate?.openquickbackup()
4946
}
50-
self.remoteinfotask = nil
47+
self.remoteestimatedlist?.abort()
48+
self.remoteestimatedlist?.stackoftasktobeestimated = nil
49+
self.remoteestimatedlist = nil
50+
self.remoteinfotaskDelegate?.setremoteinfo(remoteinfotask: nil)
5151
self.closeview()
5252
}
5353

5454
// Either abort or close
5555
@IBAction func abort(_: NSButton) {
56-
// if self.remoteinfotask?.stackoftasktobeestimated?.count ?? 0 > 0 {
57-
self.remoteinfotask?.abort()
58-
self.remoteinfotask?.stackoftasktobeestimated = nil
59-
self.remoteinfotask = nil
56+
self.remoteestimatedlist?.abort()
57+
self.remoteestimatedlist?.stackoftasktobeestimated = nil
58+
self.remoteestimatedlist = nil
6059
self.abort()
6160
self.remoteinfotaskDelegate?.setremoteinfo(remoteinfotask: nil)
62-
// }
6361
self.closeview()
6462
}
6563

@@ -88,12 +86,12 @@ class ViewControllerRemoteInfo: NSViewController, SetDismisser, Abort, Setcolor
8886
ViewControllerReference.shared.setvcref(viewcontroller: .vcremoteinfo, nsviewcontroller: self)
8987
self.remoteinfotaskDelegate = ViewControllerReference.shared.getvcref(viewcontroller: .vctabmain) as? ViewControllerMain
9088
if let remoteinfotask = self.remoteinfotaskDelegate?.getremoteinfo() {
91-
self.remoteinfotask = remoteinfotask
89+
self.remoteestimatedlist = remoteinfotask
9290
self.loaded = true
9391
self.progress.isHidden = true
9492
} else {
95-
self.remoteinfotask = RemoteinfoEstimation(viewcontroller: self, processtermination: self.processtermination)
96-
self.remoteinfotaskDelegate?.setremoteinfo(remoteinfotask: self.remoteinfotask)
93+
self.remoteestimatedlist = RemoteinfoEstimation(viewcontroller: self, processtermination: self.processtermination)
94+
self.remoteinfotaskDelegate?.setremoteinfo(remoteinfotask: self.remoteestimatedlist)
9795
}
9896
}
9997

@@ -119,21 +117,21 @@ class ViewControllerRemoteInfo: NSViewController, SetDismisser, Abort, Setcolor
119117
super.viewDidDisappear()
120118
self.diddissappear = true
121119
// Release the estimating object
122-
self.remoteinfotask?.abort()
123-
self.remoteinfotask = nil
120+
self.remoteestimatedlist?.abort()
121+
self.remoteestimatedlist = nil
124122
}
125123

126124
private func number() -> String {
127125
if self.loaded {
128126
return NSLocalizedString("Loaded cached data...", comment: "Remote info")
129127
} else {
130-
let max = self.remoteinfotask?.maxCount() ?? 0
128+
let max = self.remoteestimatedlist?.maxCount() ?? 0
131129
return NSLocalizedString("Number of tasks to estimate:", comment: "Remote info") + " " + String(describing: max)
132130
}
133131
}
134132

135133
private func dobackups() -> [NSMutableDictionary]? {
136-
let backup = self.remoteinfotask?.records?.filter { $0.value(forKey: DictionaryStrings.select.rawValue) as? Int == 1 }
134+
let backup = self.remoteestimatedlist?.records?.filter { $0.value(forKey: DictionaryStrings.select.rawValue) as? Int == 1 }
137135
return backup
138136
}
139137

@@ -150,7 +148,7 @@ class ViewControllerRemoteInfo: NSViewController, SetDismisser, Abort, Setcolor
150148
}
151149

152150
private func initiateProgressbar() {
153-
self.progress.maxValue = Double(self.remoteinfotask?.maxCount() ?? 0)
151+
self.progress.maxValue = Double(self.remoteestimatedlist?.maxCount() ?? 0)
154152
self.progress.minValue = 0
155153
self.progress.doubleValue = 0
156154
self.progress.startAnimation(self)
@@ -163,15 +161,15 @@ class ViewControllerRemoteInfo: NSViewController, SetDismisser, Abort, Setcolor
163161

164162
extension ViewControllerRemoteInfo: NSTableViewDataSource {
165163
func numberOfRows(in _: NSTableView) -> Int {
166-
return self.remoteinfotask?.records?.count ?? 0
164+
return self.remoteestimatedlist?.records?.count ?? 0
167165
}
168166
}
169167

170168
extension ViewControllerRemoteInfo: NSTableViewDelegate, Attributedestring {
171169
func tableView(_: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {
172-
guard self.remoteinfotask?.records != nil else { return nil }
173-
guard row < (self.remoteinfotask!.records?.count)! else { return nil }
174-
let object: NSDictionary = (self.remoteinfotask?.records?[row])!
170+
guard self.remoteestimatedlist?.records != nil else { return nil }
171+
guard row < (self.remoteestimatedlist!.records?.count)! else { return nil }
172+
let object: NSDictionary = (self.remoteestimatedlist?.records?[row])!
175173
switch tableColumn!.identifier.rawValue {
176174
case DictionaryStrings.transferredNumber.rawValue:
177175
let celltext = object[tableColumn!.identifier] as? String
@@ -194,11 +192,11 @@ extension ViewControllerRemoteInfo: NSTableViewDelegate, Attributedestring {
194192

195193
// Toggling selection
196194
func tableView(_: NSTableView, setObjectValue _: Any?, for tableColumn: NSTableColumn?, row: Int) {
197-
guard self.remoteinfotask?.records != nil else { return }
195+
guard self.remoteestimatedlist?.records != nil else { return }
198196
if tableColumn!.identifier.rawValue == DictionaryStrings.select.rawValue {
199-
var select: Int = self.remoteinfotask?.records![row].value(forKey: DictionaryStrings.select.rawValue) as? Int ?? 0
197+
var select: Int = self.remoteestimatedlist?.records![row].value(forKey: DictionaryStrings.select.rawValue) as? Int ?? 0
200198
if select == 0 { select = 1 } else if select == 1 { select = 0 }
201-
self.remoteinfotask?.records![row].setValue(select, forKey: DictionaryStrings.select.rawValue)
199+
self.remoteestimatedlist?.records![row].setValue(select, forKey: DictionaryStrings.select.rawValue)
202200
}
203201
self.enableexecutebutton()
204202
}
@@ -209,7 +207,7 @@ extension ViewControllerRemoteInfo {
209207
globalMainQueue.async { () -> Void in
210208
self.mainTableView.reloadData()
211209
}
212-
let progress = Double(self.remoteinfotask?.maxCount() ?? 0) - Double(self.remoteinfotask?.inprogressCount() ?? 0)
210+
let progress = Double(self.remoteestimatedlist?.maxCount() ?? 0) - Double(self.remoteestimatedlist?.inprogressCount() ?? 0)
213211
self.updateProgressbar(progress)
214212
}
215213
}

RsyncOSX/extensionVCMain.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ extension ViewControllerMain: Abort {
167167
// Abort the task
168168
func abortOperations() {
169169
_ = InterruptProcess()
170-
self.configurations?.estimatedlist = nil
171170
self.configurations?.remoteinfoestimation = nil
172171
self.working.stopAnimation(nil)
173172
self.index = nil

0 commit comments

Comments
 (0)