mirror of
https://github.com/apple/container.git
synced 2026-07-13 04:57:08 +00:00
Ensure read-only user config removed on every startup. (#1567)
- Closes #1566. - Currently on `system start` we only remove the read-only user config if the user config file exists. This means that changes to the config are processed properly on restart, but a removal is ignored, and the old read-only settings linger.
This commit is contained in:
@@ -198,16 +198,17 @@ public enum ConfigurationLoader {
|
||||
let destPath = configurationFile(in: destBase)
|
||||
|
||||
let fm = FileManager.default
|
||||
guard fm.fileExists(atPath: sourcePath.string) else { return }
|
||||
|
||||
let destDir = destPath.removingLastComponent()
|
||||
try fm.createDirectory(atPath: destDir.string, withIntermediateDirectories: true)
|
||||
|
||||
if fm.fileExists(atPath: destPath.string) {
|
||||
try fm.setAttributes([.posixPermissions: READ_AND_WRITE], ofItemAtPath: destPath.string)
|
||||
try fm.removeItem(at: URL(filePath: destPath.string))
|
||||
}
|
||||
|
||||
guard fm.fileExists(atPath: sourcePath.string) else { return }
|
||||
|
||||
let destDir = destPath.removingLastComponent()
|
||||
try fm.createDirectory(atPath: destDir.string, withIntermediateDirectories: true)
|
||||
|
||||
try fm.copyItem(
|
||||
at: URL(filePath: sourcePath.string),
|
||||
to: URL(filePath: destPath.string)
|
||||
|
||||
Reference in New Issue
Block a user