1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:28:11 +00:00

Spreadsheet: Generate file previews in memory and save directly to file

When we were asked to make a new preview text, we first generated the
whole file in the /tmp directory and then read the first 8 lines to put
them in a text box. This was doing a bit of unnecessary work at first,
but more importantly, didn't work on a given file descriptor from
FileSystemAccessServer as we were copying a file to a filename instead,
meaning that we also had to unveil the whole home directory.

Anyway, previews will be written now to a MemoryStream by the generator,
which will limit to 8 lines. File saves will omit /tmp entirely,
allowing us to tighten program unveil list a little. :^)
This commit is contained in:
Karol Kosek 2023-01-01 20:10:06 +01:00 committed by Ali Mohammad Pur
parent c74441395b
commit 29a3cdcfb7
4 changed files with 60 additions and 113 deletions

View file

@ -45,11 +45,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
TRY(Core::System::unveil("/sys/kernel/processes", "r"));
TRY(Core::System::unveil("/tmp/session/%sid/portal/filesystemaccess", "rw"));
TRY(Core::System::unveil("/tmp/session/%sid/portal/webcontent", "rw"));
// For writing temporary files when exporting.
TRY(Core::System::unveil("/tmp", "crw"));
TRY(Core::System::unveil("/etc", "r"));
TRY(Core::System::unveil(Core::StandardPaths::home_directory(), "rwc"sv));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil(nullptr, nullptr));