Skip to content

Commit

Permalink
Fix for volumes with spaces in the name
Browse files Browse the repository at this point in the history
  • Loading branch information
diegotl committed Oct 20, 2023
1 parent 680ddfd commit 3b8a010
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@ extension FileManager {
}

func merge(
atPath: String,
toPath: String,
from source: URL,
to destination: URL,
conflictResolution: ConflictResolution = .keepSource,
progressSubject: CurrentValueSubject<Double, Never>
) {
let atPath = source.path(percentEncoded: false)
let toPath = destination.path(percentEncoded: false)

let pathEnumerator = enumerator(atPath: atPath)

let allObjects = (pathEnumerator?.allObjects as? [String]) ?? []
Expand Down
10 changes: 7 additions & 3 deletions Packages/EmpusaKit/Sources/EmpusaKit/Models/EmpusaLog.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

public struct InstalledResource: Codable {
let resource: SwitchResource
let name: SwitchResource
let version: String?
var updatedAt: Date = Date()
}
Expand All @@ -13,10 +13,14 @@ public final class EmpusaLog: Codable {
resource: SwitchResource,
version: String?
) {
resources.removeAll(where: { $0.resource == resource })
resources.removeAll(where: { $0.name == resource })
resources.append(.init(
resource: resource,
name: resource,
version: version
))
}

func isResourceInstalled(_ resource: SwitchResource) -> Bool {
resources.contains(where: { $0.name == resource })
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public final class ResourceService: ResourceServiceProtocol {
let log = storageService.getLog(at: volume)

for resource in SwitchResource.allCases {
let isInstalled = log?.resources.contains(where: { $0.resource == resource }) ?? false
let isInstalled = log?.isResourceInstalled(resource) ?? false

switch resource.source {
case .github(let url, _), .forgejo(let url, _):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ extension SwitchResource {
switch self {
case .hekate, .bootLogos:
fileManager.merge(
atPath: location.appending(path: "bootloader").path(),
toPath: destination.appending(path: "bootloader").path(),
from: location.appending(path: "bootloader"),
to: destination.appending(path: "bootloader"),
progressSubject: progressSubject
)

Expand All @@ -192,8 +192,8 @@ extension SwitchResource {

case .atmosphere, .sigpatches, .tinfoil:
fileManager.merge(
atPath: location.path(),
toPath: destination.path(),
from: location,
to: destination,
progressSubject: progressSubject
)

Expand Down

0 comments on commit 3b8a010

Please sign in to comment.