mirror of
https://github.com/ninxsoft/Mist.git
synced 2025-05-14 23:24:51 -04:00
Improve cache directory error messaging
This commit is contained in:
parent
4ecef6dd13
commit
c586788a5b
10 changed files with 139 additions and 6 deletions
|
@ -25,7 +25,7 @@ struct HelperToolCommandRunner {
|
|||
case .remove:
|
||||
|
||||
guard let path: String = request.arguments.first else {
|
||||
return HelperToolCommandResponse(terminationStatus: 1, standardOutput: nil, standardError: "Invalid URL")
|
||||
return HelperToolCommandResponse(terminationStatus: 1, standardOutput: nil, standardError: "Invalid URL: \(request.arguments)")
|
||||
}
|
||||
|
||||
guard FileManager.default.fileExists(atPath: path) else {
|
||||
|
@ -38,6 +38,25 @@ struct HelperToolCommandRunner {
|
|||
} catch {
|
||||
return HelperToolCommandResponse(terminationStatus: 1, standardOutput: nil, standardError: error.localizedDescription)
|
||||
}
|
||||
case .fileAttributes:
|
||||
|
||||
guard let path: String = request.arguments.first,
|
||||
let ownerAccountName: String = request.arguments.last else {
|
||||
return HelperToolCommandResponse(terminationStatus: 1, standardOutput: nil, standardError: "Invalid attributes: \(request.arguments)")
|
||||
}
|
||||
|
||||
let attributes: [FileAttributeKey: Any] = [
|
||||
.posixPermissions: 0o755,
|
||||
.ownerAccountName: ownerAccountName,
|
||||
.groupOwnerAccountName: "staff"
|
||||
]
|
||||
|
||||
do {
|
||||
try FileManager.default.setAttributes(attributes, ofItemAtPath: path)
|
||||
return HelperToolCommandResponse(terminationStatus: 0, standardOutput: nil, standardError: nil)
|
||||
} catch {
|
||||
return HelperToolCommandResponse(terminationStatus: 1, standardOutput: nil, standardError: error.localizedDescription)
|
||||
}
|
||||
case .kill:
|
||||
ShellExecutor.shared.terminate()
|
||||
return HelperToolCommandResponse(terminationStatus: 0, standardOutput: nil, standardError: nil)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue