← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2943: Correct download logging after an app restart

 

------------------------------------------------------------
revno: 2943
author: eMTee <emtee11@xxxxxxxxx>
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Fri 2012-06-08 16:15:53 +0200
message:
  Correct download logging after an app restart
modified:
  changelog.txt
  dcpp/FinishedManager.cpp
  dcpp/QueueManager.cpp
  dcpp/QueueManager.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	2012-06-08 13:55:30 +0000
+++ changelog.txt	2012-06-08 14:15:53 +0000
@@ -8,6 +8,7 @@
 * Make the menu bar hideable (poy)
 * Add a /info hub command (poy)
 * [L#957994] Fix glitches with the file list loader (poy)
+* [1007103] Correct download logging after an app restart (emtee)
 
 -- 0.799 2012-05-05 --
 * Add icons (iceman50)

=== modified file 'dcpp/FinishedManager.cpp'
--- dcpp/FinishedManager.cpp	2012-05-15 23:26:22 +0000
+++ dcpp/FinishedManager.cpp	2012-06-08 14:15:53 +0000
@@ -169,7 +169,7 @@
 		uint64_t milliSeconds = GET_TICK() - t->getStart();
 		time_t time = GET_TIME();
 
-		int64_t size = 0;
+		int64_t size = 0, pos = 0;
 		// get downloads' file size here to avoid deadlocks
 		if(!upload) {
 			if(t->getType() == Transfer::TYPE_FULL_LIST) {
@@ -184,7 +184,7 @@
 				}
 				size = t->getSize();
 			} else {
-				size = QueueManager::getInstance()->getSize(file);
+				QueueManager::getInstance()->getSizeInfo(size, pos, file);
 				if (size == -1) {
 					// not in the queue anymore?
 					return;
@@ -199,7 +199,7 @@
 			auto it = map.find(file);
 			if(it == map.end()) {
 				FinishedFileItemPtr p = new FinishedFileItem(
-					t->getPos(),
+					pos + t->getPos(),
 					milliSeconds,
 					time,
 					upload ? File::getSize(file) : size,

=== modified file 'dcpp/QueueManager.cpp'
--- dcpp/QueueManager.cpp	2012-03-21 17:39:02 +0000
+++ dcpp/QueueManager.cpp	2012-06-08 14:15:53 +0000
@@ -799,6 +799,17 @@
 	return -1;
 }
 
+void QueueManager::getSizeInfo(int64_t& size, int64_t& pos, const string& target) noexcept {
+	Lock l(cs);
+	QueueItem* qi = fileQueue.find(target);
+	if(qi) {
+		size = qi->getSize();
+		pos = qi->getDownloadedBytes();
+	} else {
+		size = -1;
+	}
+}
+
 
 void QueueManager::move(const string& aSource, const string& aTarget) noexcept {
 	string target = Util::validateFileName(aTarget);

=== modified file 'dcpp/QueueManager.h'
--- dcpp/QueueManager.h	2012-02-11 10:48:20 +0000
+++ dcpp/QueueManager.h	2012-06-08 14:15:53 +0000
@@ -103,6 +103,7 @@
 
 	int64_t getSize(const string& target) noexcept;
 	int64_t getPos(const string& target) noexcept;
+	void getSizeInfo(int64_t& size, int64_t& pos, const string& target) noexcept;
 
 	/** Move the target location of a queued item. Running items are silently ignored */
 	void move(const string& aSource, const string& aTarget) noexcept;