diff --git a/CloverApp/Clover/SettingsView.swift b/CloverApp/Clover/SettingsView.swift index a4bc15f67..0b23b9062 100644 --- a/CloverApp/Clover/SettingsView.swift +++ b/CloverApp/Clover/SettingsView.swift @@ -1334,6 +1334,13 @@ final class SettingsViewController: self.downloadTask?.resume() } + func cleanUpdateDirectory() { + let tempDir = "/tmp/CloverXXXXX\(NSUserName())Update" + if fm.fileExists(atPath: tempDir) { + try? fm.removeItem(atPath: tempDir) + } + } + func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL) { @@ -1385,6 +1392,8 @@ final class SettingsViewController: task.terminationHandler = { t in if t.terminationStatus == 0 { self.replaceCloverV2(with: tempDir.addPath("CloverV2")) + } else { + self.cleanUpdateDirectory() } } @@ -1408,6 +1417,7 @@ final class SettingsViewController: } if (error != nil) { print(error!.localizedDescription) + self.cleanUpdateDirectory() } } @@ -1459,6 +1469,8 @@ final class SettingsViewController: try fm.removeItem(atPath: Cloverv2Path) } try fm.copyItem(atPath: newOne, toPath: Cloverv2Path) + self.cleanUpdateDirectory() + DispatchQueue.main.async { self.lastReleaseRev = nil self.lastReleaseLink = nil @@ -1486,6 +1498,7 @@ final class SettingsViewController: } try fm.createDirectory(atPath: new, withIntermediateDirectories: false, attributes: nil) try fm.copyItem(atPath: path, toPath: new.addPath(path.lastPath)) + self.cleanUpdateDirectory() DispatchQueue.main.async { self.lastReleaseRev = nil self.lastReleaseLink = nil diff --git a/CloverApp/CloverDaemonNew/CloverDaemonNew/BootInstaller.swift b/CloverApp/CloverDaemonNew/CloverDaemonNew/BootInstaller.swift index 8b27f83d6..3b9837fc8 100644 --- a/CloverApp/CloverDaemonNew/CloverDaemonNew/BootInstaller.swift +++ b/CloverApp/CloverDaemonNew/CloverDaemonNew/BootInstaller.swift @@ -31,7 +31,7 @@ final class Installer: NSObject { } else { t.launchPath = "/bin/bash" } - t.arguments = ["-c", "rm -f /tmp/Clover* && rm -f /tmp/boot0* && rm -f /tmp/boot1*"] + t.arguments = ["-c", "rm -rf /tmp/Clover* && rm -f /tmp/boot0* && rm -f /tmp/boot1*"] t.launch() } diff --git a/CloverApp/CloverDaemonNew/CloverDaemonNew/main.swift b/CloverApp/CloverDaemonNew/CloverDaemonNew/main.swift index dd8b6c7fc..1d011062a 100644 --- a/CloverApp/CloverDaemonNew/CloverDaemonNew/main.swift +++ b/CloverApp/CloverDaemonNew/CloverDaemonNew/main.swift @@ -8,7 +8,7 @@ import Foundation -let daemonVersion = "1.1.2" +let daemonVersion = "1.1.3" let fm = FileManager.default