Opened 2 years ago

Last modified 19 months ago

#2703 new bug

Renaming a file in the "Files" tab causes it to clobber existing files instead of checking.

Reported by: arielCo Owned by:
Priority: major Milestone: 2.0
Component: Core Version: 1.3.6
Keywords: Cc:

Description

For some reason (I had a hard lockup), Deluge lost the customized paths and filenames (Files tab) for all torrents. So I pause a completed torrent and change the directories and filenames to match what's already on disk. I expect Deluge to check the matching file, but instead it overwrote it. This shouldn't happen, much less if the torrent is paused.

PS: How do I reconcile Deluge with my files meanwhile?

Change History (8)

comment:1 Changed 2 years ago by arielCo

  • Summary changed from Renaming a file in Deluge causes it to clobber existing file instead of checking. to Renaming a file in the "Files" tab causes it to clobber existing files instead of checking.

comment:2 Changed 2 years ago by arielCo

Come to think of it, Deluge shouldn't do anything to a torrent's local storage while it's in the Paused state. This could be a separate ticket.

comment:3 Changed 2 years ago by Cas

There is no easy solution for this especially as libtorrent does most of the low level file manipulation.

What I usually recommend is to move torrent data to a temp location, pause torrent, rename and move directory, move back torrent data and resume.

comment:4 Changed 2 years ago by Cas

I don't agree that there is any issue with a torrent being Paused and being allowed to change storage location, it would be a major inconvenience for most users to not allow it.

comment:5 Changed 2 years ago by arielCo

There is no easy solution for this especially as libtorrent does most of the low level file manipulation.

Should it be raised with whoever maintains libtorrent?

Meanwhile, maybe checking for existence and alerting the user before calling the relevant libtorrent function would prevent nasty surprises. Something like "$new_relative_path/$new_filename already exists. Overwrite? [OK] [Cancel]"

I don't agree that there is any issue with a torrent being Paused and being allowed to change storage location, it would be a major inconvenience for most users to not allow it.

Hm, I think I get it; Paused means "no network activity", and any other actions take effect imemdiately since there is no "Submit" button. The workaround above should fit in.

comment:6 Changed 19 months ago by Cas

  • Milestone changed from Future to 1.3.x

comment:7 Changed 19 months ago by Cas

Although doesn't help with specifically with rename_files, libtorrent 1.0 move_storage method now has flags to check if files exist in target location:

The flags argument determines the behavior of the copying/moving of the files in the torrent. see move_flags_t.

        always_replace_files = 0
        fail_if_exist = 1
        dont_replace = 2

always_replace_files (default) replaces any file that exist in both the source directory and the target directory.

fail_if_exist first check to see that none of the copy operations would cause an overwrite. If it would, it will fail. Otherwise it will proceed as if it was in always_replace_files mode.

dont_replace always takes the existing file in the target directory, if there is one. The source files will still be removed in that case.

comment:8 Changed 19 months ago by Cas

  • Component changed from other/unknown to Core
  • Milestone changed from 1.3.x to 2.0

If you are using libtorrent 1.0 then with the latest addition it will fail to move instead of overwriting: [560318a5a7c7a26]

I am leaving the ticket open as probably should revisit this for 2.0.

Note: See TracTickets for help on using tickets.