Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sources/Workspace/Diagnostics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ struct BinaryArtifactsManagerError: Error, CustomStringConvertible {
.init(description: "local archive of binary target '\(targetName)' at '\(archivePath)' does not contain a binary artifact.")
}

static func localArchiveNotFound(archivePath: AbsolutePath, targetName: String) -> Self {
.init(description: "local archive of binary target '\(targetName)' at '\(archivePath)' does not exist.")
}
Comment on lines +185 to +187

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: consider changing targetName to target to ensure the caller sends an "expected" value.

Suggested change
static func localArchiveNotFound(archivePath: AbsolutePath, targetName: String) -> Self {
.init(description: "local archive of binary target '\(targetName)' at '\(archivePath)' does not exist.")
}
static func localArchiveNotFound(archivePath: AbsolutePath, target: Target) -> Self {
.init(description: "local archive of binary target '\(target.name)' at '\(archivePath)' does not exist.")
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should refactor every error so it references a target object instead of a string. This is outside the scope of this PR, so I made this one.


static func localArtifactNotFound(artifactPath: AbsolutePath, targetName: String) -> Self {
.init(description: "local binary target '\(targetName)' at '\(artifactPath)' does not contain a binary artifact.")
}
Expand Down
11 changes: 10 additions & 1 deletion Sources/Workspace/Workspace+BinaryArtifacts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ extension Workspace {
// TODO: find a better way to get the base path (not via the manifest)
let absolutePath = try manifest.path.parentDirectory.appending(RelativePath(validating: path))
if absolutePath.extension?.lowercased() == "zip" {
guard self.fileSystem.exists(absolutePath) else {
observabilityScope.emit(
BinaryArtifactsManagerError.localArchiveNotFound(
archivePath: absolutePath,
targetName: target.name
)
)
continue
}
localArtifacts.append(
.local(
packageRef: packageReference,
Expand Down Expand Up @@ -541,7 +550,7 @@ extension Workspace {
)
}
} catch {
let reason = (error as? LocalizedError)?.errorDescription ?? error.localizedDescription
let reason = error.interpolationDescription

observabilityScope.emit(BinaryArtifactsManagerError.localArtifactFailedExtraction(
artifactPath: artifact.path,
Expand Down
Loading