1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-06 19:40:08 +02:00

👌 Add quotes around paths

This commit is contained in:
2023-02-05 18:11:47 +01:00
parent 300880f3e5
commit 762527ece9
5 changed files with 35 additions and 50 deletions

View File

@ -1,14 +0,0 @@
//
// UpdateManifest.swift
// PHP Monitor
//
// Created by Nico Verbruggen on 02/02/2023.
// Copyright © 2023 Nico Verbruggen. All rights reserved.
//
import Foundation
struct ReleaseManifest: Codable {
let url: String
let sha256: String
}

View File

@ -1,5 +1,5 @@
//
// AppDelegate.swift
// Updater.swift
// PHP Monitor Updater
//
// Created by Nico Verbruggen on 01/02/2023.
@ -79,10 +79,10 @@ class Updater: NSObject, NSApplicationDelegate {
system_quiet("rm -rf \(updaterDirectory)/*.zip")
// Download the file (and follow redirects + no output on failure)
system_quiet("cd \(updaterDirectory) && curl \(manifest.url) -fLO --max-time 20")
system_quiet("cd \"\(updaterDirectory)\" && curl \(manifest.url) -fLO --max-time 20")
// Identify the downloaded file
let filename = system("cd \(updaterDirectory) && ls | grep .zip")
let filename = system("cd \"\(updaterDirectory)\" && ls | grep .zip")
.trimmingCharacters(in: .whitespacesAndNewlines)
// Ensure the zip exists
@ -92,7 +92,7 @@ class Updater: NSObject, NSApplicationDelegate {
}
// Calculate the checksum for the downloaded file
let checksum = system("openssl dgst -sha256 \(updaterDirectory)/\(filename) | awk '{print $NF}'")
let checksum = system("openssl dgst -sha256 \"\(updaterDirectory)/\(filename)\" | awk '{print $NF}'")
.trimmingCharacters(in: .whitespacesAndNewlines)
// Compare the checksums
@ -114,10 +114,10 @@ class Updater: NSObject, NSApplicationDelegate {
private func extractAndInstall(zipPath: String) async -> String {
// Remove the directory that will contain the extracted update
system_quiet("rm -rf \(updaterDirectory)/extracted")
system_quiet("rm -rf \"\(updaterDirectory)/extracted\"")
// Recreate the directory where we will unzip the .app file
system_quiet("mkdir -p \(updaterDirectory)/extracted")
system_quiet("mkdir -p \"\(updaterDirectory)/extracted\"")
// Make sure the updater directory exists
var isDirectory: ObjCBool = true
@ -126,10 +126,10 @@ class Updater: NSObject, NSApplicationDelegate {
}
// Unzip the file
system_quiet("unzip \(zipPath) -d \(updaterDirectory)/extracted")
system_quiet("unzip \"\(zipPath)\" -d \"\(updaterDirectory)/extracted\"")
// Find the .app file
let app = system("ls \(updaterDirectory)/extracted | grep .app")
let app = system("ls \"\(updaterDirectory)/extracted\" | grep .app")
.trimmingCharacters(in: .whitespacesAndNewlines)
print("Finished extracting: \(updaterDirectory)/extracted/\(app)")
@ -147,13 +147,13 @@ class Updater: NSObject, NSApplicationDelegate {
system_quiet("mv \"\(updaterDirectory)/extracted/\(app)\" \"/Applications/\(app)\"")
// Remove the zip
system_quiet("rm \(zipPath)")
system_quiet("rm \"\(zipPath)\"")
// Remove the manifest
system_quiet("rm \(manifestPath)")
system_quiet("rm \"\(manifestPath)\"")
// Write a file that is only written when we upgraded successfully
system_quiet("touch \(updaterDirectory)/upgrade.success")
system_quiet("touch \"\(updaterDirectory)/upgrade.success\"")
// Return the new location of the app
return "/Applications/\(app)"

View File

@ -1,5 +1,5 @@
//
// Alert.swift
// Utility.swift
// PHP Monitor Self-Updater
//
// Created by Nico Verbruggen on 02/02/2023.
@ -27,3 +27,8 @@ class Alert {
}
}
}
public struct ReleaseManifest: Codable {
let url: String
let sha256: String
}

View File

@ -1,6 +1,6 @@
//
// AppDelegate.swift
// PHP Monitor Updater
// PHP Monitor Self-Updater
//
// Created by Nico Verbruggen on 01/02/2023.
// Copyright © 2023 Nico Verbruggen. All rights reserved.