From 45d6e3c763499ff77c54ac43cb864de47d8efad5 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Sat, 1 May 2021 00:01:28 +0800 Subject: [PATCH] apply_load: return "0" instead of the array for asynchronous request Fixes: 2f286f939 Bug: #16 --- src/core/manager.cc | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/core/manager.cc b/src/core/manager.cc index fe5a15f1..087efce9 100644 --- a/src/core/manager.cc +++ b/src/core/manager.cc @@ -532,20 +532,23 @@ Manager::try_create_download_expand(const std::string& uri, if (flags & create_raw_data) { result.push_back(try_create_download(uri, flags, commands)); - return rawResult; - } - - std::vector paths; - paths.reserve(256); + } else { + std::vector paths; - path_expand(&paths, uri); + path_expand(&paths, uri); - if (!paths.empty()) { - for (const auto& path : paths) { - result.push_back(try_create_download(path, flags, commands)); + if (!paths.empty()) { + for (const auto& path : paths) { + result.push_back(try_create_download(path, flags, commands)); + } + } else { + result.push_back(try_create_download(uri, flags, commands)); } - } else { - result.push_back(try_create_download(uri, flags, commands)); + } + + if (result.size() == 0 || result[0].type() != torrent::Object::TYPE_STRING) { + // return "0" instead of the array if the request is asynchronous + return torrent::Object(); } return rawResult;