db/update/Container: catch C++ exceptions

This commit is contained in:
Max Kellermann 2016-11-22 11:58:18 +01:00
parent 27d368d48d
commit c5133f6088
2 changed files with 43 additions and 31 deletions

View File

@ -96,6 +96,7 @@ UpdateWalk::UpdateContainerFile(Directory &directory,
return false; return false;
} }
try {
const auto v = plugin.container_scan(pathname); const auto v = plugin.container_scan(pathname);
if (v.empty()) { if (v.empty()) {
editor.LockDeleteDirectory(contdir); editor.LockDeleteDirectory(contdir);
@ -109,13 +110,19 @@ UpdateWalk::UpdateContainerFile(Directory &directory,
// 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);
@ -129,6 +136,11 @@ UpdateWalk::UpdateContainerFile(Directory &directory,
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;
} }

View File

@ -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;
} }