This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Feature: Incomplete downloads directory (w/patch) [UPDATED]

Tags: None
(comma "," separated)
imported4-espen
Registered Member
Posts
3
Karma
0
I would like to suggest a new option for KTorrent.

The ability to have KTorrent save incomplete downloads in a "Incomplete downloads" directory, moving them to the user-selected directory when the download is finished.

The option could be added under "Preferences -> General":
Store incomplete downloads in: [Directory text box] [Browse button]

Useful when the user wants a directory with only complete downloads (eg. if sharing it over a network, where the other user don't know that the files is incomplete).

Another scenario is when amarok autoindexes new files, and does so before the file is completely downloaded, resulting in wrong tags in the collection database.

It could also be useful when using a storage media with slow seeking etc. Doing all the seeking on a fast hard drive, moving it to the slow media in one operation when finished.

* Edit: I've coded the functionality. Patch at
http://www.tveitdata.com/files/incomplete_dir_rev2.patch

Already installed the first patch? Read about the bugs in the first patch in my last post in this thread, and reapply the new one please.

First patch (with bugs):
http://www.tveitdata.com/files/incomplete_dir.patch

Last edited by imported4-espen on Thu Jul 12, 2007 2:36 pm, edited 2 times in total.
lucke
Registered Member
Posts
205
Karma
0

Mon Jul 09, 2007 11:12 am
Err, there is such functionality in 2.2. KTorrent can move files to a different directory upon completion. The "incomplete directory" would be the one you set as a download location.
imported4-espen
Registered Member
Posts
3
Karma
0

Mon Jul 09, 2007 1:44 pm
I'm aware of the new feature, it's just that I don't get why it's reversed like that. You usually want multiple download locations, not multiple incomplete download locations. I've got separate locations for movies, music, series, audio books and so on, but only need one for the incomplete downloads.

I know that some people may use only one download directory, but when you download lots of different files (movies, series, music), and want to seed them afterwards you want them to be accessible by KTorrent in the correct directories. Moving them afterwards from the one universal download directory would cause the seeding to stop. (This is especially important on private trackers where the upload is registered)

The patch does play nice with the feature you mentioned, so it doesn't remove the functionality (It's coded against the latest SVN). It downloads to the incomplete directory, and moves it over to the universal download directory the user have opted for when it's completed.
George
Moderator
Posts
5421
Karma
1

Mon Jul 09, 2007 5:49 pm
I can see your reasoning. I will check out the patch, but it will not be part of 2.2.1 (will be released next week).
George
Moderator
Posts
5421
Karma
1

Thu Jul 12, 2007 9:12 am
I'm gonna modify the patch a bit, if the user has selected both the incomplete dir and the move to the completed dir option, it doesn't make sense to move it twice.
imported4-espen
Registered Member
Posts
3
Karma
0

Thu Jul 12, 2007 2:10 pm
Your change makes sense.

Anyways. I reviewed my code, and it seems that some problems may arise if the user changes the configuration while the download is in progress. The outputdir_real also wasn't saved in the stats file (resulting in KTorrent not knowing where to put it when closed while a download was incomplete/in progress).

I've created a new patch with the changes I've listed below.
http://www.tveitdata.com/files/incomplete_dir_rev2.patch

** User changes the configuration **
Eg.
"Download to incomplete" was checked when torrent was started, and is unchecked before the download is complete: The files will be left in the incomplete downloads directory.

"Download to incomplete" was not checked when torrent was started, and is checked before the download is complete: The files may be moved to "" (probably the home directory of the user).

Added (torrentcontrol.cpp, TorrentControl::TorrentControl()):

First. We initialize the outputdir_real with QString::null
Code: Select all
      incomplete_finished = false;
      outputdir_real = QString::null;



Checks added that will counter the behavior mentioned above:

Added (torrentcontrol.cpp, TorrentControl::update()):
Code: Select all
outputdir_real!=QString::null

Code block after adding:
Code: Select all
         //Move completed files if we've saved them in a temporary/incomplete downloads folder
         if (moveFromIncomplete && outputdir_real!=QString::null) {
            QString outdir = outputdir_real;
            if(!outdir.endsWith(bt::DirSeparator()))
               outdir += bt::DirSeparator();
            incomplete_finished = true;
            changeOutputDir(outdir);
         }


Added (torrentcontrol.cpp, TorrentControl::update()):
Code: Select all
outputdir_real!=QString::null


Code block after adding:

Code: Select all
            //Move downloads saved in incomplete downloads to user-specified directory
            if(Settings::useIncompleteDir() || outputdir_real!=QString::null) {
               moveFromIncomplete = true;
            }



** Save (and load) outputdir_real in the stats file **

torrentcontrol.cpp, TorrentControl::saveStats():
right under st.write("OUTPUTDIR", cman->getDataDir());
Code: Select all
      if (outputdir_real!=QString::null) {
         st.write("OUTPUTDIR_REAL", outputdir_real);
      }


torrentcontrol.cpp, TorrentControl::loadStats():
right under outputdir = st.readString("OUTPUTDIR").stripWhiteSpace()
Code: Select all
      if (st.hasKey("OUTPUTDIR_REAL")) {
         outputdir_real = st.readString("OUTPUTDIR_REAL").stripWhiteSpace();
      }



Sorry about missing those points in the first patch. It was late night coding :P.
George
Moderator
Posts
5421
Karma
1

Sat Jul 14, 2007 8:30 am
I'll check out those change to


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]