message: add cache_path per message

Generate a message-specific cache path when needed.
Update tests, too.
This commit is contained in:
Dirk-Jan C. Binnema
2022-05-05 01:24:18 +03:00
parent 85fed37870
commit c0ae7e6860
4 changed files with 62 additions and 34 deletions

View File

@ -204,6 +204,9 @@ World!
assert_equal(message->subject(), "ättächmeñts");
const auto cache_path{message->cache_path()};
g_assert_true(!!cache_path);
g_assert_cmpuint(message->parts().size(),==,5);
{
auto&& part{message->parts().at(0)};
@ -228,6 +231,11 @@ World!
assert_equal(part.mime_type().value(), "audio/ogg");
// file consistso of 4 bytes 4..7
assert_equal(part.to_string().value(), "\004\005\006\007");
const auto fpath{*cache_path + part.cooked_filename().value()};
const auto res = part.to_file(fpath, true);
g_assert_cmpuint(*res,==,4);
g_assert_cmpuint(::access(fpath.c_str(), R_OK), ==, 0);
}
{