1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:17:34 +00:00

PackageManager: Create /usr/Ports directory when updating the ports list

When updating /usr/Ports/AvailablePorts.md, the file or even the entire
/usr/Ports directory might not exist.
To cope with this, we should be able to create it ourselves. To ensure
we are able to do this, we should unveil both /usr and /usr/Ports.
This commit is contained in:
Liav A 2023-09-15 21:49:47 +03:00 committed by Andrew Kaster
parent 4303965986
commit b6b2c6f3e2
2 changed files with 10 additions and 2 deletions

View file

@ -74,6 +74,10 @@ static Optional<Markdown::Table::Column const&> get_column_in_table(Markdown::Ta
ErrorOr<int> AvailablePort::update_available_ports_list_file()
{
if (auto error_or_void = Core::System::mkdir("/usr/Ports/"sv, 0655); error_or_void.is_error()) {
if (error_or_void.error().code() != EEXIST)
return error_or_void.release_error();
}
if (!Core::System::access("/usr/Ports/AvailablePorts.md"sv, R_OK).is_error() && FileSystem::remove("/usr/Ports/AvailablePorts.md"sv, FileSystem::RecursionMode::Disallowed).is_error()) {
outln("pkg: /usr/Ports/AvailablePorts.md exists, but can't delete it before updating it!");
return 0;