From 48310915eebc854156680ee811b450816859462a Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 1 Aug 2016 22:25:03 +0900 Subject: [PATCH] Replace "/" with "-" in magnet dn name when used as in-memory download name --- src/download_helper.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/download_helper.cc b/src/download_helper.cc index ad1bf648..42b96513 100644 --- a/src/download_helper.cc +++ b/src/download_helper.cc @@ -249,7 +249,11 @@ createBtMagnetRequestGroup(const std::string& magnetLink, bittorrent::loadMagnet(magnetLink, dctx); auto torrentAttrs = bittorrent::getTorrentAttrs(dctx); bittorrent::adjustAnnounceUri(torrentAttrs, option); - dctx->getFirstFileEntry()->setPath(torrentAttrs->name); + // torrentAttrs->name may contain "/", but we use basename of + // FileEntry::getPath() to print out in-memory download entry. + // Since "/" is treated as separator, we replace it with "-". + dctx->getFirstFileEntry()->setPath( + util::replace(torrentAttrs->name, "/", "-")); rg->setDownloadContext(dctx); rg->clearPostDownloadHandler(); rg->addPostDownloadHandler(