Major update for stability
This commit is contained in:
@@ -34,6 +34,7 @@ final class SyncJob {
|
||||
var watchPath: String = ""
|
||||
var watchDebounceSeconds: Int = 3
|
||||
var lastWatchEventAt: Date? = nil
|
||||
var allowUnattendedDelete: Bool = false
|
||||
|
||||
init(
|
||||
name: String = "New Sync Job",
|
||||
@@ -71,6 +72,7 @@ final class SyncJob {
|
||||
self.watchPath = ""
|
||||
self.watchDebounceSeconds = 3
|
||||
self.lastWatchEventAt = nil
|
||||
self.allowUnattendedDelete = false
|
||||
}
|
||||
|
||||
var exclusions: [String] {
|
||||
|
||||
@@ -43,6 +43,27 @@ final class SyncRun {
|
||||
RsyncSummary.parse(output + "\n" + errorOutput)
|
||||
}
|
||||
|
||||
|
||||
static func sanitizedLog(_ value: String, maxBytes: Int = 2_000_000) -> String {
|
||||
let stripped = stripANSI(value)
|
||||
let redacted = stripped
|
||||
.replacingOccurrences(of: #"(?i)--password-file(?:=|\s+)[^\s]+"#, with: "--password-file=[REDACTED]", options: .regularExpression)
|
||||
.replacingOccurrences(of: #"(?i)(password|passwd|token|secret)=([^\s]+)"#, with: "$1=[REDACTED]", options: .regularExpression)
|
||||
|
||||
let data = Data(redacted.utf8)
|
||||
guard data.count > maxBytes else { return redacted }
|
||||
let prefix = data.prefix(maxBytes)
|
||||
return String(decoding: prefix, as: UTF8.self) + "\n\n[Log truncated by Rsync Manager for safety and storage limits.]\n"
|
||||
}
|
||||
|
||||
private static func stripANSI(_ value: String) -> String {
|
||||
value.replacingOccurrences(
|
||||
of: #"\u001B\[[0-9;?]*[ -/]*[@-~]"#,
|
||||
with: "",
|
||||
options: .regularExpression
|
||||
)
|
||||
}
|
||||
|
||||
var exportText: String {
|
||||
var text = "Rsync Manager Run Log\n"
|
||||
text += "Job: \(jobName)\n"
|
||||
|
||||
Reference in New Issue
Block a user