Commit c5133f60 authored by Max Kellermann's avatar Max Kellermann

db/update/Container: catch C++ exceptions

parent 27d368d4
...@@ -96,38 +96,50 @@ UpdateWalk::UpdateContainerFile(Directory &directory, ...@@ -96,38 +96,50 @@ UpdateWalk::UpdateContainerFile(Directory &directory,
return false; return false;
} }
const auto v = plugin.container_scan(pathname); try {
if (v.empty()) { const auto v = plugin.container_scan(pathname);
editor.LockDeleteDirectory(contdir); if (v.empty()) {
return false; editor.LockDeleteDirectory(contdir);
} return false;
}
TagBuilder tag_builder; TagBuilder tag_builder;
for (const auto &vtrack : v) { for (const auto &vtrack : v) {
Song *song = Song::NewFile(vtrack.c_str(), *contdir); Song *song = Song::NewFile(vtrack.c_str(), *contdir);
// shouldn't be necessary but it's there.. // shouldn't be necessary but it's there..
song->mtime = info.mtime; song->mtime = info.mtime;
const auto vtrack_fs = AllocatedPath::FromUTF8(vtrack.c_str()); try {
// TODO: check vtrack_fs.IsNull() const auto vtrack_fs =
AllocatedPath::FromUTF8Throw(vtrack.c_str());
const auto child_path_fs = AllocatedPath::Build(pathname, const auto child_path_fs = AllocatedPath::Build(pathname,
vtrack_fs); vtrack_fs);
plugin.ScanFile(child_path_fs, plugin.ScanFile(child_path_fs,
add_tag_handler, &tag_builder); add_tag_handler, &tag_builder);
} catch (const std::runtime_error &e) {
song->Free();
LogError(e);
continue;
}
tag_builder.Commit(song->tag); tag_builder.Commit(song->tag);
{ {
const ScopeDatabaseLock protect; const ScopeDatabaseLock protect;
contdir->AddSong(song); contdir->AddSong(song);
} }
modified = true; modified = true;
FormatDefault(update_domain, "added %s/%s", FormatDefault(update_domain, "added %s/%s",
directory.GetPath(), vtrack.c_str()); directory.GetPath(), vtrack.c_str());
}
} catch (const std::runtime_error &e) {
editor.LockDeleteDirectory(contdir);
LogError(e);
return false;
} }
return true; return true;
......
...@@ -266,10 +266,10 @@ ScanMusicEmu(Music_Emu *emu, unsigned song_num, ...@@ -266,10 +266,10 @@ ScanMusicEmu(Music_Emu *emu, unsigned song_num,
assert(ti != nullptr); assert(ti != nullptr);
AtScopeExit(ti) { gme_free_info(ti); };
ScanGmeInfo(*ti, song_num, gme_track_count(emu), ScanGmeInfo(*ti, song_num, gme_track_count(emu),
handler, handler_ctx); handler, handler_ctx);
gme_free_info(ti);
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment