Skip to content

Commit 676fc54

Browse files
committed
Refactor log record handling and error catching
Removed conditional check for adding summary log records in Logging.swift, simplifying the logic. Updated ReadLogRecordsJSON.swift to use a standard catch block for error handling and commented out the previous catch with error propagation.
1 parent 868dab3 commit 676fc54

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

RsyncUI/Model/Loggdata/Logging.swift

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -97,33 +97,31 @@ final class Logging {
9797
// setCurrentDateonConfiguration(configrecords: [Typelogdata]).
9898
// Must set -1 to get correct num in log
9999
func addlogpermanentstore(schedulerecords: [Typelogdata]) {
100-
if SharedReference.shared.addsummarylogrecord {
101-
_ = schedulerecords.map { logdata in
102-
let hiddenID = logdata.0
103-
let stats = logdata.1
104-
let currendate = Date()
105-
let date = currendate.en_string_from_date()
106-
if let config = getconfig(hiddenID: hiddenID) {
107-
let resultannotaded: String? = if config.task == SharedReference.shared.snapshot {
108-
if let snapshotnum = config.snapshotnum {
109-
"(" + String(snapshotnum - 1) + ") " + stats
110-
} else {
111-
"(" + "1" + ") " + stats
112-
}
100+
_ = schedulerecords.map { logdata in
101+
let hiddenID = logdata.0
102+
let stats = logdata.1
103+
let currendate = Date()
104+
let date = currendate.en_string_from_date()
105+
if let config = getconfig(hiddenID: hiddenID) {
106+
let resultannotaded: String? = if config.task == SharedReference.shared.snapshot {
107+
if let snapshotnum = config.snapshotnum {
108+
"(" + String(snapshotnum - 1) + ") " + stats
113109
} else {
114-
stats
115-
}
116-
var inserted: Bool = addlogexisting(hiddenID: hiddenID,
117-
result: resultannotaded ?? "",
118-
date: date)
119-
// Record does not exist, create new LogRecord (not inserted)
120-
if inserted == false {
121-
inserted = addlognew(hiddenID: hiddenID, result: resultannotaded ?? "", date: date)
110+
"(" + "1" + ") " + stats
122111
}
112+
} else {
113+
stats
114+
}
115+
var inserted: Bool = addlogexisting(hiddenID: hiddenID,
116+
result: resultannotaded ?? "",
117+
date: date)
118+
// Record does not exist, create new LogRecord (not inserted)
119+
if inserted == false {
120+
inserted = addlognew(hiddenID: hiddenID, result: resultannotaded ?? "", date: date)
123121
}
124122
}
125-
WriteLogRecordsJSON(localeprofile, logrecords)
126123
}
124+
WriteLogRecordsJSON(localeprofile, logrecords)
127125
}
128126

129127
// Extract numbers as Double values

RsyncUI/Model/Storage/ReadLogRecordsJSON.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,16 @@ final class ReadLogRecordsJSON {
3333
return validhiddenIDs.contains(item.hiddenID) ? item : nil
3434
}
3535

36+
} catch {
37+
Logger.process.error("ReadLogRecordsJSON - \(profile ?? "default profile", privacy: .public): some ERROR reading logrecords from permanent storage")
38+
}
39+
/*
3640
} catch let e {
3741
Logger.process.error("ReadLogRecordsJSON - \(profile ?? "default profile", privacy: .public): some ERROR reading logrecords from permanent storage")
3842
let error = e
3943
path.propagateError(error: error)
4044
}
45+
*/
4146
return nil
4247
}
4348

0 commit comments

Comments
 (0)