Skip to content

Commit

Permalink
fixes an issue where cleanup trigger was potentially being run in a c…
Browse files Browse the repository at this point in the history
…ontext that didn't have permissions to clean up the files.
  • Loading branch information
bartreardon committed Mar 27, 2024
1 parent 71bd8fe commit f953005
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 2 additions & 7 deletions Outset/Outset.swift
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ struct Outset: ParsableCommand {
processItems(loginEveryDir)
}
if !folderContents(path: loginOncePrivilegedDir).isEmpty || !folderContents(path: loginEveryPrivilegedDir).isEmpty {
FileManager.default.createFile(atPath: loginPrivilegedTrigger, contents: nil)
createTrigger(loginPrivilegedTrigger)
}
}

Expand Down Expand Up @@ -237,18 +237,13 @@ struct Outset: ParsableCommand {
let currentUser = NSUserName()
if consoleUser == currentUser {
processItems(onDemandDir)
createTrigger(cleanupTrigger)
} else {
writeLog("User \(currentUser) is not the current console user. Skipping on-demand run.")
}
} else {
writeLog("No current user session. Skipping on-demand run.")
}
FileManager.default.createFile(atPath: cleanupTrigger, contents: nil)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
if checkFileExists(path: cleanupTrigger) {
pathCleanup(pathname: cleanupTrigger)
}
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions Outset/Utils/FileUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ func deletePath(_ path: String) {
}
}

func createTrigger(_ path: String) {
FileManager.default.createFile(atPath: path, contents: nil)
}

func mountDmg(dmg: String) -> String {
// Attaches dmg and returns the path
let cmd = "/usr/bin/hdiutil attach -nobrowse -noverify -noautoopen \(dmg)"
Expand Down

0 comments on commit f953005

Please sign in to comment.