mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
Merge pull request #1203 from lonerOrz/downcs
Fix: Clean up failed downloads
This commit is contained in:
@@ -573,8 +573,29 @@ Popup {
|
||||
ToastService.showError(I18n.tr("settings.color-scheme.download.error.title"), I18n.tr("settings.color-scheme.download.error.description", {
|
||||
"scheme": schemeName
|
||||
}) + "\n" + errorDetails);
|
||||
downloading = false;
|
||||
downloadingScheme = "";
|
||||
// Clean up the partially downloaded directory on failure
|
||||
var cleanupScript = "rm -rf '" + targetDir + "'";
|
||||
var cleanupProcess = Qt.createQmlObject(`
|
||||
import QtQuick
|
||||
import Quickshell.Io
|
||||
Process {
|
||||
id: cleanupProcess
|
||||
command: ["sh", "-c", ` + JSON.stringify(cleanupScript) + `]
|
||||
}
|
||||
`, root, "CleanupProcess_" + schemeName);
|
||||
|
||||
cleanupProcess.exited.connect(function (cleanupExitCode) {
|
||||
if (cleanupExitCode === 0) {
|
||||
Logger.d("ColorSchemeDownload", "Partially downloaded scheme directory cleaned up:", targetDir);
|
||||
} else {
|
||||
Logger.w("ColorSchemeDownload", "Failed to clean up partially downloaded scheme directory:", targetDir);
|
||||
}
|
||||
downloading = false;
|
||||
downloadingScheme = "";
|
||||
cleanupProcess.destroy();
|
||||
});
|
||||
|
||||
cleanupProcess.running = true;
|
||||
}
|
||||
root.lastStderrOutput = "";
|
||||
downloadProcess.destroy();
|
||||
|
||||
Reference in New Issue
Block a user