From d9b39f5ac694c131401dcaff9996063fa01c011b Mon Sep 17 00:00:00 2001 From: pyroscope Date: Mon, 18 Jun 2018 19:41:53 +0200 Subject: [PATCH] d.custom.if_z: return default also for existing but empty value --- src/command_download.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/command_download.cc b/src/command_download.cc index a31d6857..70ec427a 100644 --- a/src/command_download.cc +++ b/src/command_download.cc @@ -286,7 +286,8 @@ retrieve_d_custom_if_z(core::Download* download, const torrent::Object::list_typ throw torrent::bencode_error("d.custom.if_z: Missing default argument."); try { - return download->bencode()->get_key("rtorrent").get_key("custom").get_key_string(key); + const std::string& val = download->bencode()->get_key("rtorrent").get_key("custom").get_key_string(key); + return val.empty() ? itr->as_string() : val; } catch (torrent::bencode_error& e) { return itr->as_string(); }