Even more ArchUpdater fixes

ArchUpdaterService:properly check for errors
This commit is contained in:
Ly-sec 2025-08-31 16:56:52 +02:00
parent 4520ed3cbf
commit 2f8472f720
2 changed files with 20 additions and 17 deletions

View file

@ -26,6 +26,10 @@ Singleton {
property bool checkFailed: false property bool checkFailed: false
property string lastCheckError: "" property string lastCheckError: ""
// Monitoring state
property string capturedErrorText: ""
property string capturedSuccessText: ""
// Computed properties // Computed properties
readonly property bool aurBusy: checkAurUpdatesProcess.running || checkAurOnlyProcess.running readonly property bool aurBusy: checkAurUpdatesProcess.running || checkAurOnlyProcess.running
readonly property int updates: repoPackages.length readonly property int updates: repoPackages.length
@ -55,7 +59,6 @@ Singleton {
interval: 5000 interval: 5000
repeat: false repeat: false
onTriggered: { onTriggered: {
Logger.log("ArchUpdater", "Refreshing package lists after update...")
doPoll() doPoll()
} }
} }
@ -66,7 +69,6 @@ Singleton {
interval: 30000 // Increased to 30 seconds to allow more time interval: 30000 // Increased to 30 seconds to allow more time
repeat: false repeat: false
onTriggered: { onTriggered: {
Logger.log("ArchUpdater", "Update timeout reached, checking for failures...")
checkForUpdateFailures() checkForUpdateFailures()
} }
} }
@ -94,7 +96,6 @@ Singleton {
onExited: function (exitCode) { onExited: function (exitCode) {
if (exitCode !== 0 && updateInProgress) { if (exitCode !== 0 && updateInProgress) {
// No update processes found, update likely completed // No update processes found, update likely completed
Logger.log("ArchUpdater", "No update processes detected, marking update as complete")
updateInProgress = false updateInProgress = false
updateMonitorTimer.stop() updateMonitorTimer.stop()
errorCheckTimer.stop() errorCheckTimer.stop()
@ -114,11 +115,10 @@ Singleton {
// Process to check for errors in log file (only when update is in progress) // Process to check for errors in log file (only when update is in progress)
Process { Process {
id: errorCheckProcess id: errorCheckProcess
command: ["sh", "-c", "if [ -f /tmp/archupdater_output.log ]; then grep -i 'error\\|failed to build\\|could not resolve\\|unable to satisfy\\|failed to install\\|failed to upgrade' /tmp/archupdater_output.log | grep -v 'ERROR_DETECTED' | tail -1; fi"] command: ["sh", "-c", "if [ -f /tmp/archupdater_output.log ]; then grep -i 'failed to build\\|could not resolve\\|unable to satisfy\\|failed to install\\|failed to upgrade\\|error:' /tmp/archupdater_output.log | grep -v 'ERROR_DETECTED' | tail -1; fi"]
onExited: function (exitCode) { onExited: function (exitCode) {
if (exitCode === 0 && updateInProgress) { if (exitCode === 0 && updateInProgress && capturedErrorText.trim() !== "") {
// Error found in log // Error found in log
Logger.error("ArchUpdater", "Error detected in log file")
updateInProgress = false updateInProgress = false
updateFailed = true updateFailed = true
updateCompleteTimer.stop() updateCompleteTimer.stop()
@ -135,9 +135,7 @@ Singleton {
} }
stdout: StdioCollector { stdout: StdioCollector {
onStreamFinished: { onStreamFinished: {
if (text && text.trim() !== "") { capturedErrorText = text || ""
Logger.error("ArchUpdater", "Captured error from log:", text.trim())
}
} }
} }
} }
@ -145,11 +143,10 @@ Singleton {
// Process to check for successful completion // Process to check for successful completion
Process { Process {
id: successCheckProcess id: successCheckProcess
command: ["sh", "-c", "if [ -f /tmp/archupdater_output.log ]; then grep -i ':: Running post-transaction hooks\\|:: Processing package changes\\|upgrading.*\\.\\.\\.\\|installing.*\\.\\.\\.\\|removing.*\\.\\.\\.' /tmp/archupdater_output.log | tail -1; fi"] command: ["sh", "-c", "if [ -f /tmp/archupdater_output.log ]; then grep -i 'Update complete!\\|:: Running post-transaction hooks\\|:: Processing package changes\\|upgrading.*\\.\\.\\.\\|installing.*\\.\\.\\.\\|removing.*\\.\\.\\.' /tmp/archupdater_output.log | tail -1; fi"]
onExited: function (exitCode) { onExited: function (exitCode) {
if (exitCode === 0 && updateInProgress) { if (exitCode === 0 && updateInProgress && capturedSuccessText.trim() !== "") {
// Success indicators found // Success indicators found
Logger.log("ArchUpdater", "Update completed successfully")
updateInProgress = false updateInProgress = false
updateFailed = false updateFailed = false
updateCompleteTimer.stop() updateCompleteTimer.stop()
@ -164,6 +161,11 @@ Singleton {
}, 1000) }, 1000)
} }
} }
stdout: StdioCollector {
onStreamFinished: {
capturedSuccessText = text || ""
}
}
} }
// Timer to check for success more frequently when update is in progress // Timer to check for success more frequently when update is in progress
@ -202,7 +204,6 @@ Singleton {
} }
function checkForUpdateFailures() { function checkForUpdateFailures() {
Logger.error("ArchUpdater", "Checking for update failures...")
updateInProgress = false updateInProgress = false
updateFailed = true updateFailed = true
updateCompleteTimer.stop() updateCompleteTimer.stop()
@ -415,6 +416,8 @@ Singleton {
updateFailed = false updateFailed = false
lastUpdateError = "" lastUpdateError = ""
updateInProgress = true updateInProgress = true
capturedErrorText = ""
capturedSuccessText = ""
const terminal = Quickshell.env("TERMINAL") const terminal = Quickshell.env("TERMINAL")
if (!terminal) { if (!terminal) {
@ -453,6 +456,8 @@ Singleton {
updateFailed = false updateFailed = false
lastUpdateError = "" lastUpdateError = ""
updateInProgress = true updateInProgress = true
capturedErrorText = ""
capturedSuccessText = ""
const terminal = Quickshell.env("TERMINAL") const terminal = Quickshell.env("TERMINAL")
if (!terminal) { if (!terminal) {

View file

@ -51,8 +51,6 @@ Singleton {
property string name: "" property string name: ""
property int weatherLastFetch: 0 property int weatherLastFetch: 0
property var weather: null property var weather: null
} }
} }
@ -120,8 +118,8 @@ Singleton {
return return
} }
if ((adapter.weatherLastFetch === "") || (adapter.weather === null) || (adapter.latitude === "") || (adapter.longitude === "") if ((adapter.weatherLastFetch === "") || (adapter.weather === null) || (adapter.latitude === "")
|| (adapter.name !== Settings.data.location.name) || (adapter.longitude === "") || (adapter.name !== Settings.data.location.name)
|| (Time.timestamp >= adapter.weatherLastFetch + weatherUpdateFrequency)) { || (Time.timestamp >= adapter.weatherLastFetch + weatherUpdateFrequency)) {
getFreshWeather() getFreshWeather()
} }