mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-04 21:29:21 +00:00
Own the download factory until commit
A malformed data uri threw before commit, and nothing deleted it.
This commit is contained in:
+5
-2
@@ -195,14 +195,14 @@ Manager::try_create_download(const std::string& uri, int flags, const command_li
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Adding download.
|
// Adding download.
|
||||||
DownloadFactory* f = new DownloadFactory(this);
|
auto f = std::make_unique<DownloadFactory>(this);
|
||||||
|
|
||||||
f->variables()["tied_to_file"] = (int64_t)(bool)(flags & create_tied);
|
f->variables()["tied_to_file"] = (int64_t)(bool)(flags & create_tied);
|
||||||
f->commands().insert(f->commands().end(), commands.begin(), commands.end());
|
f->commands().insert(f->commands().end(), commands.begin(), commands.end());
|
||||||
|
|
||||||
f->set_start(flags & create_start);
|
f->set_start(flags & create_start);
|
||||||
f->set_print_log(!(flags & create_quiet));
|
f->set_print_log(!(flags & create_quiet));
|
||||||
f->slot_finished([f]() { delete f; });
|
f->slot_finished([factory = f.get()]() { delete factory; });
|
||||||
|
|
||||||
if (is_data_uri(uri)) {
|
if (is_data_uri(uri)) {
|
||||||
// Allow the use of data URIs, primarily for JSON-RPC which
|
// Allow the use of data URIs, primarily for JSON-RPC which
|
||||||
@@ -216,6 +216,9 @@ Manager::try_create_download(const std::string& uri, int flags, const command_li
|
|||||||
}
|
}
|
||||||
|
|
||||||
f->commit();
|
f->commit();
|
||||||
|
|
||||||
|
// From here the finished slot deletes it.
|
||||||
|
f.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user