Skip to content

Commit

Permalink
config(qemu): migration fails if Images directory does not exist
Browse files Browse the repository at this point in the history
Fixes #4266
  • Loading branch information
osy committed Aug 7, 2022
1 parent 9544177 commit c692698
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Configuration/UTMQemuConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,14 @@ extension UTMQemuConfiguration {
let fileManager = FileManager.default
let imagesURL = packageURL.appendingPathComponent(QEMUPackageFileName.images.rawValue)
let dataURL = packageURL.appendingPathComponent(Self.dataDirectoryName)
guard !fileManager.fileExists(atPath: dataURL.path) && fileManager.fileExists(atPath: imagesURL.path) else {
throw UTMQemuConfigurationError.migrationFailed
if fileManager.fileExists(atPath: imagesURL.path) {
guard !fileManager.fileExists(atPath: dataURL.path) else {
throw UTMQemuConfigurationError.migrationFailed
}
try await Task.detached {
try fileManager.moveItem(at: imagesURL, to: dataURL)
}.value
}
try await Task.detached {
try fileManager.moveItem(at: imagesURL, to: dataURL)
}.value
// update any drives
for i in 0..<drives.count {
if !drives[i].isExternal, let oldImageURL = drives[i].imageURL {
Expand Down

0 comments on commit c692698

Please sign in to comment.