Mercurial > dedupe
comparison DataController.cpp @ 100:f4ebbfa3ffae
Beautify progressreport update, and do lstat rather than stat when checking if a file is a link
| author | Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no> |
|---|---|
| date | Thu, 13 Feb 2014 14:55:11 +0100 |
| parents | c7da835ea912 |
| children | 6bc013d5788b |
comparison
equal
deleted
inserted
replaced
| 99:b821d6270741 | 100:f4ebbfa3ffae |
|---|---|
| 5 #include "CachedEditDistance.hpp" | 5 #include "CachedEditDistance.hpp" |
| 6 #include "SqliteDBLink.hpp" | 6 #include "SqliteDBLink.hpp" |
| 7 | 7 |
| 8 #include "Exception/PermissionException.hpp" | 8 #include "Exception/PermissionException.hpp" |
| 9 | 9 |
| 10 #include <QtCore/QDebug> | |
| 10 #include <QtCore/QTimer> | 11 #include <QtCore/QTimer> |
| 11 #include <QtCore/QUrl> | 12 #include <QtCore/QUrl> |
| 12 | 13 |
| 13 #include <QtGui/QApplication> | 14 #include <QtGui/QApplication> |
| 14 #include <QtGui/QDesktopServices> | 15 #include <QtGui/QDesktopServices> |
| 45 } | 46 } |
| 46 if (!wpath.empty()) { | 47 if (!wpath.empty()) { |
| 47 if (fs::is_directory(dir_iter->status()) ) { | 48 if (fs::is_directory(dir_iter->status()) ) { |
| 48 findFiles(QString::fromStdWString(wpath), list); | 49 findFiles(QString::fromStdWString(wpath), list); |
| 49 } | 50 } |
| 50 if (fs::is_regular_file(dir_iter->status()) ) { | 51 if (fs::is_regular_file(dir_iter->symlink_status()) ) { |
| 51 list << QString::fromStdWString(wpath); | 52 list << QString::fromStdWString(wpath); |
| 52 } | 53 } |
| 53 } | 54 } |
| 54 } | 55 } |
| 55 } | 56 } |
| 77 { | 78 { |
| 78 QStringList paths = findFiles(dir); | 79 QStringList paths = findFiles(dir); |
| 79 | 80 |
| 80 QDateTime last = QDateTime::currentDateTime(); | 81 QDateTime last = QDateTime::currentDateTime(); |
| 81 | 82 |
| 82 dblink.keepOnlyFromPrefix(dir.path(), paths); | 83 qDebug() << "Start Delete"; |
| 84 dblink.keepOnlyFromPrefix(dir.path(), paths, true); | |
| 85 dblink.commit(dir.path()); | |
| 86 qDebug() << "End Delete"; | |
| 83 | 87 |
| 84 std::auto_ptr<QProgressBar> bar; | 88 std::auto_ptr<QProgressBar> bar; |
| 85 | 89 |
| 86 progressMax = paths.size(); | 90 progressMax = paths.size(); |
| 87 | 91 |
| 427 } | 431 } |
| 428 | 432 |
| 429 void DataController::progressUpdate(int p, int max) | 433 void DataController::progressUpdate(int p, int max) |
| 430 { | 434 { |
| 431 QString str; | 435 QString str; |
| 432 if (p == 0) | 436 if (max == 0) { |
| 433 str.sprintf("Progress %6.2f%%", p * 100.0 / max); | 437 str.sprintf("Progress %6.2f%%", 100.0); |
| 434 else if (p == max) { | |
| 435 str.sprintf("\b\b\b\b\b\b\b%6.2f%%\n", 100.0); | |
| 436 } | 438 } |
| 437 else { | 439 else { |
| 438 str.sprintf("\b\b\b\b\b\b\b%6.2f%%", p * 100.0 / max); | 440 if (p == 0) |
| 441 str.sprintf("Progress %6.2f%%", p * 100.0 / max); | |
| 442 else if (p == max) { | |
| 443 str.sprintf("\b\b\b\b\b\b\b%6.2f%%\n", 100.0); | |
| 444 } | |
| 445 else { | |
| 446 str.sprintf("\b\b\b\b\b\b\b%6.2f%%", p * 100.0 / max); | |
| 447 } | |
| 448 } | |
| 449 if (p == max) { | |
| 450 str+="\n"; | |
| 439 } | 451 } |
| 440 std::cout<<str.toStdString(); | 452 std::cout<<str.toStdString(); |
| 441 std::cout.flush(); | 453 std::cout.flush(); |
| 442 } | 454 } |
| 443 | 455 |
