Skip to content

Commit d6ca511

Browse files
committed
Refactor code formatting and error handling
Removed unnecessary blank lines and improved code formatting across multiple files for consistency. Updated error handling in ActorReadLogRecordsJSON and ActorReadSynchronizeConfigurationJSON to suppress unwanted error propagation messages. Adjusted indentation and parameter alignment in several SwiftUI views for better readability.
1 parent e308c87 commit d6ca511

File tree

14 files changed

+52
-55
lines changed

14 files changed

+52
-55
lines changed

RsyncUI/Model/Execution/EstimateExecute/Estimate.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ import OSLog
1010
import ParseRsyncOutput
1111
import RsyncProcess
1212

13-
1413
@MainActor
1514
final class Estimate {
1615
private var localconfigurations: [SynchronizeConfiguration]
1716
private var structprofile: String?
1817

1918
weak var localprogressdetails: ProgressDetails?
2019

21-
2220
var stackoftasks: [Int]?
2321
var synchronizeIDwitherror: String = ""
2422

@@ -65,7 +63,6 @@ final class Estimate {
6563
}
6664
}
6765

68-
6966
// Used in Estimate
7067
private func validatetagging(_ lines: Int, _ tagged: Bool) throws {
7168
if lines > SharedReference.shared.alerttagginglines, tagged == false {
@@ -90,11 +87,10 @@ final class Estimate {
9087
selecteduuids: Set<UUID>,
9188
progressdetails: ProgressDetails?)
9289
{
93-
9490
structprofile = profile
9591
localconfigurations = configurations
9692
localprogressdetails = progressdetails
97-
93+
9894
stackoftasks = computestackoftasks(selecteduuids)
9995
localprogressdetails?.setprofileandnumberofconfigurations(structprofile, stackoftasks?.count ?? 0)
10096
Logger.process.debugmessageonly("Estimate: START ESTIMATION")

RsyncUI/Model/Execution/EstimateExecute/Execute.swift

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,12 @@ final class Execute {
134134
filehandler: @escaping (Int) -> Void,
135135
updateconfigurations: @escaping ([SynchronizeConfiguration]) -> Void)
136136
{
137-
138137
structprofile = profile
139138
localconfigurations = configurations
140139
localprogressdetails = progressdetails
141140
localfilehandler = filehandler
142141
localupdateconfigurations = updateconfigurations
143-
142+
144143
guard selecteduuids.count > 0 else { return }
145144
let taskstosynchronize = localconfigurations.filter {
146145
selecteduuids.contains($0.id) && $0.task != SharedReference.shared.halted
@@ -149,7 +148,6 @@ final class Execute {
149148
guard stackoftasks?.count ?? 0 > 0 else { return }
150149
Logger.process.debugmessageonly("Execute: START EXECUTION")
151150
startexecution()
152-
153151
}
154152

155153
@discardableResult
@@ -177,7 +175,6 @@ final class Execute {
177175
}
178176

179177
extension Execute {
180-
181178
private func processtermination(stringoutputfromrsync: [String]?, _ hiddenID: Int?) {
182179
guard setabort == false else { return }
183180
// Log records
@@ -187,11 +184,11 @@ extension Execute {
187184
// Prepareoutput prepares output from rsync for extracting the numbers only.
188185
// It removes all lines except the last 20 lines where summarized numbers are put
189186
let preparedoutputfromrsync = PrepareOutputFromRsync().prepareOutputFromRsync(stringoutputfromrsync)
190-
187+
191188
if SharedReference.shared.addsummarylogrecord {
192189
do {
193190
let stats = try ParseRsyncOutput(preparedoutputfromrsync,
194-
SharedReference.shared.rsyncversion3 ? .ver3 : .openrsync).getstats()
191+
SharedReference.shared.rsyncversion3 ? .ver3 : .openrsync).getstats()
195192
if let logData = (hiddenID ?? -1, stats) as? Typelogdata {
196193
schedulerecords.append(logData)
197194
}
@@ -205,14 +202,14 @@ extension Execute {
205202
Logger.process.debugmessageonly("Execute: getstats() FAILED")
206203
}
207204
}
208-
205+
209206
guard stackoftasks?.count ?? 0 > 0 else {
210207
let update = Logging(profile: structprofile,
211208
configurations: localconfigurations)
212209
let updateconfigurations = update.setCurrentDateonConfiguration(configrecords: configrecords)
213210
// Send date stamped configurations back to caller
214211
localupdateconfigurations(updateconfigurations)
215-
212+
216213
Logger.process.debugmessageonly("Execute: EXECUTION is completed")
217214
guard SharedReference.shared.addsummarylogrecord else { return }
218215
// Update logrecords
@@ -246,7 +243,7 @@ extension Execute {
246243
localnoestprogressdetails?.appenduuidwithdatatosynchronize(config.id)
247244
}
248245
}
249-
246+
250247
guard stackoftasks?.count ?? 0 > 0 else {
251248
let update = Logging(profile: structprofile,
252249
configurations: localconfigurations)

RsyncUI/Model/Execution/EstimateExecute/RemoteDataNumbers.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// swiftlint:disable line_length
99

1010
import Foundation
11-
import ParseRsyncOutput
1211
import OSLog
12+
import ParseRsyncOutput
1313

1414
@MainActor
1515
struct RemoteDataNumbers: Identifiable, Hashable {
@@ -49,7 +49,7 @@ struct RemoteDataNumbers: Identifiable, Hashable {
4949
var stats: String?
5050
// A reduced number of output
5151
var preparedoutputfromrsync: [String]?
52-
52+
5353
init(stringoutputfromrsync: [String]?,
5454
config: SynchronizeConfiguration?)
5555
{
@@ -99,11 +99,11 @@ struct RemoteDataNumbers: Identifiable, Hashable {
9999
totalnumbers = "0"
100100

101101
datatosynchronize = false
102-
102+
103103
Logger.process.debugmessageonly("RemoteDataNumbers: getstats() FAILED")
104104
return
105105
}
106-
106+
107107
filestransferred = parsersyncoutput.formatted_filestransferred
108108

109109
filestransferred_Int = parsersyncoutput.numbersonly?.filestransferred ?? 0
@@ -132,8 +132,6 @@ struct RemoteDataNumbers: Identifiable, Hashable {
132132
}
133133
}
134134
}
135-
136-
137135
}
138136

139137
// swiftlint:enable line_length

RsyncUI/Model/Global/AlertError.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ final class AlertError {
1616
func alert(error: Error) {
1717
activeError = error
1818
}
19-
19+
2020
func clearError() {
2121
activeError = nil
2222
}

RsyncUI/Model/Storage/Actors/ActorReadLogRecordsJSON.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,17 @@ actor ActorReadLogRecordsJSON {
3737
let item = LogRecords(element)
3838
return validhiddenIDs.contains(item.hiddenID) ? item : nil
3939
}
40-
41-
} catch let e {
40+
} catch {
4241
Logger.process.error("ActorReadLogRecordsJSON - \(profile ?? "default profile", privacy: .public): some ERROR reading logrecords from permanent storage")
43-
let error = e
44-
await path.propagateError(error: error)
4542
}
43+
/*
44+
I do not wish to receive that annoying message.
45+
} catch let e {
46+
Logger.process.error("ActorReadLogRecordsJSON - \(profile ?? "default profile", privacy: .public): some ERROR reading logrecords from permanent storage")
47+
let error = e
48+
await path.propagateError(error: error)
49+
}
50+
*/
4651
return nil
4752
}
4853

RsyncUI/Model/Storage/Actors/ActorReadSynchronizeConfigurationJSON.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,17 @@ actor ActorReadSynchronizeConfigurationJSON {
9292

9393
return tasks
9494

95-
} catch let e {
95+
} catch {
9696
Logger.process.error("ActorReadSynchronizeConfigurationJSON - \(profile ?? "default profile", privacy: .public): some ERROR reading synchronize configurations from permanent storage")
97-
let error = e
98-
await path.propagateError(error: error)
9997
}
98+
/*
99+
I do not wish to receive that annoying message.
100+
} catch let e {
101+
Logger.process.error("ActorReadSynchronizeConfigurationJSON - \(profile ?? "default profile", privacy: .public): some ERROR reading synchronize configurations from permanent storage")
102+
let error = e
103+
await path.propagateError(error: error)
104+
}
105+
*/
100106
return nil
101107
}
102108

RsyncUI/Views/Detailsview/EstimationInProgressView.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ struct EstimationInProgressView: View {
4747
.onAppear {
4848
// Either is there some selceted tasks or if not
4949
// the EstimateTasks selects all tasks to be estimated
50-
50+
5151
Estimate(profile: profile,
52-
configurations: configurations,
53-
selecteduuids: selecteduuids,
54-
progressdetails: progressdetails)
52+
configurations: configurations,
53+
selecteduuids: selecteduuids,
54+
progressdetails: progressdetails)
5555
}
5656
.progressViewStyle(.circular)
5757
}
@@ -62,9 +62,9 @@ struct EstimationInProgressView: View {
6262
// Either is there some selceted tasks or if not
6363
// the EstimateTasks selects all tasks to be estimated
6464
Estimate(profile: profile,
65-
configurations: configurations,
66-
selecteduuids: selecteduuids,
67-
progressdetails: progressdetails)
65+
configurations: configurations,
66+
selecteduuids: selecteduuids,
67+
progressdetails: progressdetails)
6868
}
6969
}
7070

RsyncUI/Views/LogView/LogfileView.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ struct LogfileView: View {
7474
}
7575
}
7676
}
77-
7877
}
7978

8079
struct LogfileRecords: Identifiable {

RsyncUI/Views/ProgressView/SynchronizeProgressView.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ struct SynchronizeProgressView: View {
2121
Color.gray.opacity(0.2),
2222
lineWidth: 12
2323
)
24-
24+
2525
if max > 0 {
26-
2726
Circle()
2827
.trim(from: 0, to: min(progress / max, 1.0))
2928
.stroke(
@@ -40,7 +39,7 @@ struct SynchronizeProgressView: View {
4039
.rotationEffect(.degrees(-90))
4140
.animation(.spring(response: 0.6, dampingFraction: 0.8), value: progress)
4241
}
43-
42+
4443
VStack(spacing: 4) {
4544
Text("\(Int(progress))")
4645
.font(.system(size: 36, weight: .bold, design: .rounded))
@@ -57,4 +56,3 @@ struct SynchronizeProgressView: View {
5756
.animation(.default, value: progress)
5857
}
5958
}
60-

RsyncUI/Views/Restore/RestoreTableView.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ struct RestoreTableView: View {
7575
}
7676

7777
if gettingfilelist { ProgressView() }
78-
if restore.restorefilesinprogress {SynchronizeProgressView(max: restore.max, progress: restore.progress, statusText: "Restoring...") }
78+
if restore.restorefilesinprogress { SynchronizeProgressView(max: restore.max, progress: restore.progress, statusText: "Restoring...") }
7979

8080
if restore.selectedconfig?.offsiteServer.isEmpty == true {
8181
DismissafterMessageView(dismissafter: 2, mytext: NSLocalizedString("Use macOS Finder to restore files from attached discs.", comment: ""))
@@ -343,4 +343,3 @@ extension RestoreTableView {
343343
}
344344

345345
// swiftlint:enable line_length
346-

0 commit comments

Comments
 (0)