Skip to content
Merged
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
2 changes: 1 addition & 1 deletion include/vcpkg/paragraphs.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace vcpkg::Paragraphs
// If an error occurs, the Expected will be in the error state.
// Otherwise, if the port is known, the maybe_scfl.get()->source_control_file contains the loaded port information.
// Otherwise, maybe_scfl.get()->source_control_file is nullptr.
PortLoadResult try_load_port(const ReadOnlyFilesystem& fs, StringView port_name, const PortLocation& port_location);
PortLoadResult try_load_port(const ReadOnlyFilesystem& fs, const PortLocation& port_location);
// Identical to try_load_port, but the port unknown condition is mapped to an error.
PortLoadResult try_load_port_required(const ReadOnlyFilesystem& fs,
StringView port_name,
Expand Down
34 changes: 17 additions & 17 deletions src/vcpkg/paragraphs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ namespace vcpkg::Paragraphs
});
}

PortLoadResult try_load_port(const ReadOnlyFilesystem& fs, StringView port_name, const PortLocation& port_location)
PortLoadResult try_load_port(const ReadOnlyFilesystem& fs, const PortLocation& port_location)
{
StatsTimer timer(g_load_ports_stats);

Expand Down Expand Up @@ -441,34 +441,34 @@ namespace vcpkg::Paragraphs
std::string{}};
}

if (fs.exists(port_location.port_directory, IgnoreErrors{}))
{
return PortLoadResult{LocalizedString::from_raw(port_location.port_directory)
.append_raw(": ")
.append_raw(ErrorPrefix)
.append(msgPortMissingManifest2, msg::package_name = port_name),
std::string{}};
}

return PortLoadResult{LocalizedString::from_raw(port_location.port_directory)
.append_raw(": ")
.append_raw(ErrorPrefix)
.append(msgPortDoesNotExist, msg::package_name = port_name),
std::string{}};
return PortLoadResult{SourceControlFileAndLocation{}, std::string{}};
}

PortLoadResult try_load_port_required(const ReadOnlyFilesystem& fs,
StringView port_name,
const PortLocation& port_location)
{
auto load_result = try_load_port(fs, port_name, port_location);
auto load_result = try_load_port(fs, port_location);
Copy link
Collaborator

Choose a reason for hiding this comment

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

If this is the only caller, should try_load_port be inlined?

Copy link
Member Author

Choose a reason for hiding this comment

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

I intend to add other callers :)

Copy link
Member Author

Choose a reason for hiding this comment

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

(Specifically, how I discovered this situation: overlay-ports want to try-load-port and it's OK if there's no port there: because it might be a directory containing overlays rather than the overlay itself)

auto maybe_res = load_result.maybe_scfl.get();
if (maybe_res)
{
auto res = maybe_res->source_control_file.get();
if (!res)
{
load_result.maybe_scfl = msg::format_error(msgPortDoesNotExist, msg::package_name = port_name);
if (fs.exists(port_location.port_directory, IgnoreErrors{}))
{
load_result.maybe_scfl = LocalizedString::from_raw(port_location.port_directory)
.append_raw(": ")
.append_raw(ErrorPrefix)
.append(msgPortMissingManifest2, msg::package_name = port_name);
}
else
{
load_result.maybe_scfl = LocalizedString::from_raw(port_location.port_directory)
.append_raw(": ")
.append_raw(ErrorPrefix)
.append(msgPortDoesNotExist, msg::package_name = port_name);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/registries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ namespace
return m_scfls.get_lazy(path, [&, this]() {
std::string spdx_location = "git+https://github.com/Microsoft/vcpkg#ports/";
spdx_location.append(port_name.data(), port_name.size());
return Paragraphs::try_load_port(m_fs, port_name, PortLocation{path, std::move(spdx_location)})
return Paragraphs::try_load_port_required(m_fs, port_name, PortLocation{path, std::move(spdx_location)})
Copy link
Member Author

Choose a reason for hiding this comment

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

As an aside, I think this behavior is wrong, and this really should return the nullptr case. However, fixing that I believe is what resulted in #1486 (comment)

This PR intentionally does not change existing product behavior.

.maybe_scfl;
});
}
Expand Down
Loading