Skip to content

Commit 6aecf95

Browse files
committed
fixup
1 parent 7f299e1 commit 6aecf95

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

Sources/Commands/SwiftPackageRegistryTool.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ public struct SwiftPackageRegistryTool: ParsableCommand {
8484
var url: String
8585

8686
func run(_ swiftTool: SwiftTool) throws {
87-
guard let url = URL(string: self.url),
88-
url.scheme == "https"
87+
guard let url = URL(string: self.url)//,
88+
//url.scheme == "https"
8989
else {
9090
throw RegistryConfigurationError.invalidURL(self.url)
9191
}

Sources/PackageRegistry/RegistryClient.swift

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,12 +378,17 @@ public final class RegistryClient {
378378
// prepare target download locations
379379
let downloadPath = destinationPath.withExtension("zip")
380380
do {
381+
// prepare directories
382+
if !fileSystem.exists(downloadPath.parentDirectory) {
383+
try fileSystem.createDirectory(downloadPath.parentDirectory, recursive: true)
384+
}
385+
// clear out download path if exists
386+
try fileSystem.removeFileTree(downloadPath)
381387
// validate that the destination does not already exist
382388
guard !fileSystem.exists(destinationPath) else {
383389
throw RegistryError.pathAlreadyExists(destinationPath)
384390
}
385-
// clear out download path if exists
386-
try fileSystem.removeFileTree(downloadPath)
391+
try fileSystem.createDirectory(destinationPath, recursive: true)
387392
} catch {
388393
return completion(.failure(error))
389394
}
@@ -421,7 +426,9 @@ public final class RegistryClient {
421426
// TODO: Bail if archive contains relative paths or overlapping files
422427
archiver.extract(from: downloadPath, to: destinationPath) { result in
423428
defer { try? fileSystem.removeFileTree(downloadPath) }
424-
completion(result)
429+
completion(result.mapError { error in
430+
StringError("failed extracting '\(downloadPath)' to '\(destinationPath)': \(error)")
431+
})
425432
}
426433
} catch {
427434
completion(.failure(error))
@@ -628,7 +635,7 @@ extension RegistryClient {
628635
}
629636

630637
public struct AdditionalMetadata: Codable {
631-
public let description: String
638+
public let description: String?
632639

633640
public init(description: String) {
634641
self.description = description

Sources/Workspace/Workspace.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3352,7 +3352,11 @@ extension Workspace {
33523352
throw StringError("registry not configured")
33533353
}
33543354

3355-
let downloadPath = self.location.registryDownloadDirectory.appending(components: package.identity.description, version.description)
3355+
guard case (let scope, let name)? = package.identity.scopeAndName else {
3356+
throw StringError("invalid package identity")
3357+
}
3358+
3359+
let downloadPath = self.location.registryDownloadDirectory.appending(components: scope.description, name.description, version.description)
33563360
if self.fileSystem.exists(downloadPath) {
33573361
return downloadPath
33583362
}

0 commit comments

Comments
 (0)