y500 / libtorrent

Automatically exported from code.google.com/p/libtorrent
0 stars 0 forks source link

Maybe missing code in storage.cpp default_storage::rename_file() in trunk #717

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I seems that during the recent changes regarding default_storage::rename_file() 
a new problem was created.

...
if (!exists(old_name, ec.ec))
{
    if (ec.ec == boost::system::errc::no_such_file_or_directory)
    {
        ec.ec.clear();
        return;
    }
...

should have

if (!exists(old_name, ec.ec))
{
    if (ec.ec == boost::system::errc::no_such_file_or_directory)
    {
        if (!m_mapped_files)
        { m_mapped_files.reset(new file_storage(m_files)); }
        m_mapped_files->rename_file(index, new_filename);
        ec.ec.clear();
        return;
    }
...

Original issue reported on code.google.com by webmas...@massaroddel.de on 11 Jan 2015 at 8:06

GoogleCodeExporter commented 8 years ago
thanks, fixed in [10718]. It introduced some extra indentation and is probably 
best viewed with:

  svn diff -c 10718 -x -b

Original comment by arvid.no...@gmail.com on 13 Jan 2015 at 6:29

GoogleCodeExporter commented 8 years ago
I think there is still a problem because the else case for exists() is still 
there.
..
        else if (ec.ec)
        {
            // if exists fails, report that error
            ec.file = index;
            ec.operation = storage_error::rename;
            return;
        }

Original comment by webmas...@massaroddel.de on 14 Jan 2015 at 8:24

GoogleCodeExporter commented 8 years ago
that's "else if (ec.ec)", so, only invoked if exists() fails. However, at a 
second look, exists() is a bit unintuitive. If the file doesn't exist, instead 
of just returning false, it returns false _and_ let's ec be set to 
no_such_file_or_directory. I assumed that not to be the case and forgot to 
verify.

Original comment by arvid.no...@gmail.com on 15 Jan 2015 at 1:51

GoogleCodeExporter commented 8 years ago
fixed in [10726].

Original comment by arvid.no...@gmail.com on 15 Jan 2015 at 2:31