Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #748 from pyroscope/d_custom_if_z-empty-val
d.custom.if_z: return default also for existing but empty value
  • Loading branch information
rakshasa committed Jun 19, 2018
2 parents 08aa287 + d9b39f5 commit 7804ed3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/command_download.cc
Expand Up @@ -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();
}
Expand Down

0 comments on commit 7804ed3

Please sign in to comment.