From 8e1cf7a7e02a547632c90daad34269a18925fa59 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sun, 12 Apr 2020 18:39:03 -0700 Subject: [PATCH] erpt: amend logic for culling orphan attachments --- .../source/erpt/srv/erpt_srv_journal_for_attachments.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal_for_attachments.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal_for_attachments.cpp index 1244be2ec..66060f3b5 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal_for_attachments.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal_for_attachments.cpp @@ -118,12 +118,17 @@ namespace ams::erpt::srv { auto record_guard = SCOPE_GUARD { delete record; }; - R_UNLESS(R_SUCCEEDED(Stream::GetStreamSize(std::addressof(record->info.attachment_size), Attachment::FileName(record->info.attachment_id).name)), erpt::ResultCorruptJournal()); + if (R_FAILED(Stream::GetStreamSize(std::addressof(record->info.attachment_size), Attachment::FileName(record->info.attachment_id).name))) { + continue; + } if (record->info.flags.Test() && JournalForReports::RetrieveRecord(record->info.owner_report_id) != nullptr) { /* NOTE: Nintendo does not check the result of storing the new record... */ record_guard.Cancel(); StoreRecord(record); + } else { + /* If the attachment has no owner (or we deleted the report), delete the file associated with it. */ + Stream::DeleteStream(Attachment::FileName(record->info.attachment_id).name); } }