Permalink
Browse files

Fixed status bug.

  • Loading branch information...
1 parent 0d4f782 commit ee947895b85d086ecda6b0df82962267d627acde @wilson-ko wilson-ko committed Jul 7, 2012
View
@@ -214,7 +214,7 @@ void Download::calculateEstimatedTime() {
struct time estimated_time;
double speed = getStatistics().download_speed;
- double time_in_seconds = ( swift::Size(getID()) - swift::Complete(getID()) ) / (speed*1024);
+ double time_in_seconds = swift::Size(getID()) == 0 ? DBL_MAX : ( swift::Size(getID()) - swift::Complete(getID()) ) / (speed*1024);
double time_left = time_in_seconds;
int days = (int) floor(time_left / SECONDS_PER_DAY);
@@ -378,13 +378,19 @@ void downloadCallback(int fd, short event, void* arg) {
std::cout << "Download Name: " << DownloadManager::active_download->getFilename() << std::endl;
std::cout << "Status: " << DownloadManager::active_download->getStatus() << std::endl;
+ double progress = floorf(((swift::Complete(DownloadManager::active_download->getID()) * 10000.0) /
+ swift::Size(DownloadManager::active_download->getID()) * 1.0) + 0.5) / 100;
+
if (DownloadManager::active_download->getStatus() == UPLOADING || DownloadManager::active_download->getStatus() == DOWNLOADING){
- std::cout << "Percentage downloaded: " << floorf(((swift::Complete(DownloadManager::active_download->getID()) * 10000.0) /
- swift::Size(DownloadManager::active_download->getID()) * 1.0) + 0.5) / 100 << std::endl;
+ std::cout << "Percentage downloaded: " << progress << std::endl;
}
bool is_unlocked = false;
- if (swift::SeqComplete(DownloadManager::active_download->getID()) == swift::Size(DownloadManager::active_download->getID()) ||
+ // Check for NaN
+ if (isnan(progress)) {
+ std::cout << "No peers..." << std::endl;
+
+ } else if (swift::SeqComplete(DownloadManager::active_download->getID()) == swift::Size(DownloadManager::active_download->getID()) ||
DownloadManager::active_download->getStatus() == PAUSED) {
if (DownloadManager::active_download->getStatus() != UPLOADING && DownloadManager::active_download->getStatus() != PAUSED) {
@@ -12,7 +12,7 @@
#DEFAULT_STOPWORDS_FILE = os.path.join(LIBRARYNAME, 'Core', 'Tag', 'stop_snowball.filter')
# Workaround for now:
-DEFAULT_STOPWORDS_FILE = u"/mtd_down/widgets/user/SamyGO/SamyGO/tribler/Tribler/Core/Tag/stop_snowball.filter" #os.path.join(os.path.dirname(__file__), 'stop_snowball.filter')
+DEFAULT_STOPWORDS_FILE = u"/home/kelvin/swiftarm/tribler/Tribler/Core/Tag/stop_snowball.filter" #os.path.join(os.path.dirname(__file__), 'stop_snowball.filter')
# TODO: Improve this code ^
class StopwordsFilter:
View
Binary file not shown.

0 comments on commit ee94789

Please sign in to comment.