From 4303965986d58e3d7475802d1c4e3f97436093be Mon Sep 17 00:00:00 2001 From: Liav A Date: Fri, 15 Sep 2023 21:46:17 +0300 Subject: [PATCH] PackageManager: Inform the user if AvailablePorts.md doesn't exist If we need to read from /usr/Ports/AvailablePorts.md, but the file does not exist, then warn the user in an informative way. --- Userland/Utilities/pkg/AvailablePort.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Userland/Utilities/pkg/AvailablePort.cpp b/Userland/Utilities/pkg/AvailablePort.cpp index 1d5350f571..f11829edc9 100644 --- a/Userland/Utilities/pkg/AvailablePort.cpp +++ b/Userland/Utilities/pkg/AvailablePort.cpp @@ -123,6 +123,10 @@ static ErrorOr extract_port_name_from_column(Markdown::Table::Column con ErrorOr> AvailablePort::read_available_ports_list() { + if (Core::System::access("/usr/Ports/AvailablePorts.md"sv, R_OK).is_error()) { + warnln("pkg: /usr/Ports/AvailablePorts.md doesn't exist, did you run pkg -u first?"); + return Error::from_errno(ENOENT); + } auto available_ports_file = TRY(Core::File::open("/usr/Ports/AvailablePorts.md"sv, Core::File::OpenMode::Read, 0600)); auto content_buffer = TRY(available_ports_file->read_until_eof()); auto content = StringView(content_buffer);