Skip to content

Commit

Permalink
Report read-only volume update errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tagavari committed Aug 9, 2022
1 parent 22c8210 commit 8903e90
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
2 changes: 2 additions & 0 deletions AirMessage/Controllers/SoftwareUpdateViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ class SoftwareUpdateViewController: NSViewController {
alertMessage = NSLocalizedString("message.update.error.invalid_package", comment: "")
case .internalError:
alertMessage = NSLocalizedString("message.update.error.internal", comment: "")
case .readOnlyVolume:
alertMessage = NSLocalizedString("message.update.error.readonly_volume", comment: "")
}

let alert = NSAlert()
Expand Down
1 change: 1 addition & 0 deletions AirMessage/Data/UpdateErrorCode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ enum UpdateErrorCode: Int {
case download = 0
case badPackage = 1
case internalError = 2
case readOnlyVolume = 3
}
19 changes: 13 additions & 6 deletions AirMessage/Helper/UpdateHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -400,12 +400,19 @@ private class UpdateDownloadURLDelegate: ForwardCompatURLSessionDelegate, URLSes
let destinationFolder = activeAppPath.deletingLastPathComponent()

//Get the temporary directory
let temporaryDirectory = try FileManager.default.url(
for: .itemReplacementDirectory,
in: .userDomainMask,
appropriateFor: destinationFolder,
create: true
)
let temporaryDirectory: URL
do {
temporaryDirectory = try FileManager.default.url(
for: .itemReplacementDirectory,
in: .userDomainMask,
appropriateFor: destinationFolder,
create: true
)
} catch CocoaError.fileWriteVolumeReadOnly {
LogManager.log("Can't apply update, app volume is read-only", level: .notice)
notifyError(code: UpdateErrorCode.readOnlyVolume, message: "App volume is read-only")
return
}

//Get the download targets
let zippedFile = temporaryDirectory.appendingPathComponent(UUID().uuidString + ".zip", isDirectory: false)
Expand Down
1 change: 1 addition & 0 deletions AirMessage/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
"message.update.error.download"="Couldn't download update file";
"message.update.error.invalid_package"="An invalid update package was received";
"message.update.error.internal"="An internal error occurred while processing this update";
"message.update.error.readonly_volume"="Please move AirMessage to the Applications folder and try again";
"message.update.error.os_compat"="Please update to macOS %d.%d.%d and try again.";

"message.register.error.title"="Failed to register this computer";
Expand Down
1 change: 1 addition & 0 deletions AirMessage/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
"message.update.error.download"="Impossible de télécharger la mise à jour";
"message.update.error.invalid_package"="Des données de mise à jour non valides ont été reçues";
"message.update.error.internal"="Une erreur interne s'est produite lors du traitement de cette mise à jour";
"message.update.error.readonly_volume"="Veuillez déplacer AirMessage dans le dossier Applications et réessayer";
"message.update.error.os_compat"="Veuillez mettre à jour vers macOS %d.%d.%d et réessayer";

"message.register.error.title"="Impossible d'enregistrer cet ordinateur";
Expand Down
1 change: 1 addition & 0 deletions AirMessage/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
"message.update.error.download"="アップデートファイルのダウンロードができない";
"message.update.error.invalid_package"="無効なアップデートパッケージを受信しました";
"message.update.error.internal"="このアップデートの処理中に内部エラーが発生しました";
"message.update.error.readonly_volume"="AirMessage をアプリケーションのフォルダに移動して、もう一度お試しください";
"message.update.error.os_compat"="macOS %d.%d.%d にアップデートして再度お試しください。";

"message.register.error.title"="このコンピュータの登録に失敗しました";
Expand Down

0 comments on commit 8903e90

Please sign in to comment.