Bug 146997 - Data lost when changing the download directory
Summary: Data lost when changing the download directory
Status: RESOLVED FIXED
Alias: None
Product: ktorrent
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Joris Guisson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-20 13:58 UTC by Henri Hesse
Modified: 2007-06-22 18:30 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Henri Hesse 2007-06-20 13:58:47 UTC
Version:           2.2rc1 (using KDE KDE 3.5.7)
Installed from:    Ubuntu Packages
OS:                Linux

When changing the download place for a torrent and downloading it at the same time, ktorrent starts to copy the old files to the new directory as it should, but as the download process is still going on it shows the error message of lost data (wether I want download the data again or ignore the problem)

The quick solution is to stop/pause the download and start it again when the transfer of the uncomplete data is done, but it might be nice if the was an automatic system for the dum guys like me how doesn't think before they do something :-)

Heres a screenshot of the situation: http://metalguru.fi/valokuva2.png
Comment 1 Joris Guisson 2007-06-20 18:31:22 UTC
Is this torrent controlled by the QM ?
Comment 2 Henri Hesse 2007-06-20 23:42:45 UTC
Yes, it was... and I tested to do the same thing to a torrent that is user controlled and discovered that torrent automatically stops untill the transfer is complete :-) So the problem obviously has something to do with the QM.
Comment 3 Joris Guisson 2007-06-21 12:38:35 UTC
We stop the torrent, but the QM starts it again.
Comment 4 Joris Guisson 2007-06-22 18:30:23 UTC
SVN commit 678949 by guisson:

Make sure QM cannot start torrents which are currently moving their data files.

BUG: 146997



 M  +3 -0      interfaces/torrentinterface.h  
 M  +1 -1      torrent/queuemanager.cpp  
 M  +9 -2      torrent/torrentcontrol.cpp  
 M  +4 -2      torrent/torrentcontrol.h  


--- branches/extragear/kde3/network/ktorrent/libktorrent/interfaces/torrentinterface.h #678948:678949
@@ -428,6 +428,9 @@
 		
 		/// Check if there is enough diskspace available for this torrent
 		virtual bool checkDiskSpace(bool emit_sig = true) = 0;
+		
+		/// Are we in the process of moving files
+		virtual bool isMovingFiles() const = 0;
 	signals:
 		/**
 		 * Emited when we have finished downloading.
--- branches/extragear/kde3/network/ktorrent/libktorrent/torrent/queuemanager.cpp #678948:678949
@@ -474,7 +474,7 @@
 						++user_seeding;
 				}
 
-				if (!s.user_controlled)
+				if (!s.user_controlled && !tc->isMovingFiles())
 				{
 					if (s.completed)
 						seed_queue.append(tc);
--- branches/extragear/kde3/network/ktorrent/libktorrent/torrent/torrentcontrol.cpp #678948:678949
@@ -117,6 +117,7 @@
 		// by default no torrent limits
 		upload_gid = download_gid = 0;
 		upload_limit = download_limit = 0;
+		moving_files = false;
 	}
 
 
@@ -142,7 +143,7 @@
 	void TorrentControl::update()
 	{
 		UpdateCurrentTime();
-		if (stats.status == kt::CHECKING_DATA)
+		if (stats.status == kt::CHECKING_DATA || moving_files)
 			return;
 		
 		if (istats.io_error)
@@ -322,7 +323,7 @@
 	void TorrentControl::start()
 	{	
 		// do not start running torrents
-		if (stats.running || stats.status == kt::ALLOCATING_DISKSPACE)
+		if (stats.running || stats.status == kt::ALLOCATING_DISKSPACE || moving_files)
 			return;
 
 		stats.stopped_by_error = false;
@@ -817,6 +818,7 @@
 		Out(SYS_GEN|LOG_NOTICE) << "Moving data for torrent " << stats.torrent_name << " to " << new_dir << endl;
 		
 		bool start = false;
+		int old_prio = getPriority();
 		
 		//check if torrent is running and stop it before moving data
 		if(stats.running)
@@ -825,6 +827,7 @@
 			this->stop(false);
 		}
 		
+		moving_files = true;
 		try
 		{
 			QString nd;
@@ -858,11 +861,15 @@
 		catch (Error& err)
 		{			
 			Out(SYS_GEN|LOG_IMPORTANT) << "Could not move " << stats.output_path << " to " << new_dir << ". Exception: " << err.toString() << endl;
+			moving_files = false;
 			return false;
 		}
 		
+		moving_files = false;
 		if(start)
+		{
 			this->start();
+		}
 		
 		return true;
 	}
--- branches/extragear/kde3/network/ktorrent/libktorrent/torrent/torrentcontrol.h #678948:678949
@@ -260,6 +260,9 @@
 		///Get the PeerManager
 		const PeerManager * getPeerMgr() const;
 		
+		/// Are we in the process of moving files
+		bool isMovingFiles() const {return moving_files;}
+		
 	public slots:
 		/**
 		 * Update the object, should be called periodically.
@@ -344,10 +347,9 @@
 		
 		bool prealloc;
 		PreallocationThread* prealoc_thread;
-		
 		DataCheckerThread* dcheck_thread;
-		
 		TimeStamp last_diskspace_check;
+		bool moving_files;
 		
 		struct InternalStats
 		{