Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi_download 无法设置下载文件本地存放目录 #36

Open
shenlanzifa opened this issue Dec 22, 2015 · 1 comment
Open

multi_download 无法设置下载文件本地存放目录 #36

shenlanzifa opened this issue Dec 22, 2015 · 1 comment

Comments

@shenlanzifa
Copy link

在 multi_download 中设置settings 的save_path字段不起作用,文件还是被存放到默认路径。经过查看源代码,发现 std::string multi_download::file_name() 函数有点小问题。下面是修改后的:
std::string multi_download::file_name() const
{
// 如果文件名为空, 则生成默认文件名.
if (m_file_name.empty())
{
// 构造默认文件名. 如果url中的文件名为空, 那么就默认为index.html, 否则
// 使用url中指定的文件名, 除非settings指定了保存文件路径及文件名.
m_file_name = fs::path(detail::utf8_ansi(m_final_url.path())).leaf().string();
if (m_file_name == "/" || m_file_name == "")
m_file_name = fs::path(m_final_url.query()).leaf().string();
if (m_file_name == "/" || m_file_name == "" || m_file_name == ".")
m_file_name = "index.html";
}

if (!m_settings.save_path.empty())
{
    if (fs::is_directory(m_settings.save_path))
    {
        fs::path p = m_settings.save_path / m_file_name;
        if (m_file_name != p.string())
        {
            m_file_name = p.string();
        }

    }
    else
    {
        m_file_name = m_settings.save_path.string();
    }
}

return m_file_name;

}
这样设置save_path就起作用了,修改后还没发现别的问题,希望作者审核下。

@Jackarain
Copy link
Member

能否提交个pull request或patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants