← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2317: Fix share files instantly

 

------------------------------------------------------------
revno: 2317
committer: eMTee <emtee11@xxxxxxxxx>
branch nick: dcplusplus
timestamp: Wed 2010-12-01 19:49:09 +0100
message:
  Fix share files instantly
modified:
  changelog.txt
  dcpp/QueueManager.cpp
  dcpp/QueueManagerListener.h
  dcpp/ShareManager.cpp
  dcpp/ShareManager.h


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'changelog.txt'
--- changelog.txt	2010-11-30 18:55:29 +0000
+++ changelog.txt	2010-12-01 18:49:09 +0000
@@ -40,6 +40,7 @@
 * [L#506288] Save settings periodically (poy)
 * Add titles to various menus (poy)
 * [L#535556] Make sure menus are not too wide (poy)
+* [L#610466] Fix share files instantly when unfinished folder and download target is not on the same drive (emtee)
 
 -- 0.770 2010-07-05 --
 * [L#550300] Catch more potential file corruptions (thanks bigmuscle)

=== modified file 'dcpp/QueueManager.cpp'
--- dcpp/QueueManager.cpp	2010-09-02 12:22:51 +0000
+++ dcpp/QueueManager.cpp	2010-12-01 18:49:09 +0000
@@ -1035,6 +1035,7 @@
 void QueueManager::moveFile_(const string& source, const string& target) {
 	try {
 		File::renameFile(source, target);
+		getInstance()->fire(QueueManagerListener::FileMoved(), target);
 	} catch(const FileException& e1) {
 		// Try to just rename it to the correct name at least
 		string newTarget = Util::getFilePath(source) + Util::getFileName(target);

=== modified file 'dcpp/QueueManagerListener.h'
--- dcpp/QueueManagerListener.h	2010-02-11 21:44:13 +0000
+++ dcpp/QueueManagerListener.h	2010-12-01 18:49:09 +0000
@@ -45,6 +45,8 @@
 	typedef X<13> RecheckAlreadyFinished;
 	typedef X<14> RecheckDone;
 
+	typedef X<15> FileMoved;
+
 	virtual void on(Added, QueueItem*) throw() { }
 	virtual void on(Finished, QueueItem*, const string&, int64_t) throw() { }
 	virtual void on(Removed, QueueItem*) throw() { }
@@ -61,6 +63,8 @@
 	virtual void on(RecheckNoTree, const string&) throw() { }
 	virtual void on(RecheckAlreadyFinished, const string&) throw() { }
 	virtual void on(RecheckDone, const string&) throw() { }
+
+	virtual void on(FileMoved, const string&) throw() { }
 };
 
 } // namespace dcpp

=== modified file 'dcpp/ShareManager.cpp'
--- dcpp/ShareManager.cpp	2010-11-27 14:48:00 +0000
+++ dcpp/ShareManager.cpp	2010-12-01 18:49:09 +0000
@@ -1378,16 +1378,15 @@
 	return Directory::Ptr();
 }
 
-void ShareManager::on(QueueManagerListener::Finished, QueueItem* qi, const string& dir, int64_t speed) throw() {
+void ShareManager::on(QueueManagerListener::FileMoved, const string& n) throw() {
 	if(BOOLSETTING(ADD_FINISHED_INSTANTLY)) {
 		// Check if finished download is supposed to be shared
 		Lock l(cs);
-		const string& n = qi->getTarget();
 		for(StringMapIter i = shares.begin(); i != shares.end(); i++) {
 			if(Util::strnicmp(i->first, n, i->first.size()) == 0 && n[i->first.size() - 1] == PATH_SEPARATOR) {
 				try {
 					// Schedule for hashing, it'll be added automatically later on...
-					HashManager::getInstance()->checkTTH(n, qi->getSize(), 0);
+					HashManager::getInstance()->checkTTH(n, File::getSize(n), 0);
 				} catch(const Exception&) {
 					// Not a vital feature...
 				}

=== modified file 'dcpp/ShareManager.h'
--- dcpp/ShareManager.h	2010-11-19 15:11:20 +0000
+++ dcpp/ShareManager.h	2010-12-01 18:49:09 +0000
@@ -283,7 +283,7 @@
 	virtual int run();
 
 	// QueueManagerListener
-	virtual void on(QueueManagerListener::Finished, QueueItem* qi, const string& dir, int64_t speed) throw();
+	virtual void on(QueueManagerListener::FileMoved, const string& n) throw();
 
 	// HashManagerListener
 	virtual void on(HashManagerListener::TTHDone, const string& fname, const TTHValue& root) throw();