Mercurial > dedupe
changeset 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 | b821d6270741 |
| children | 6c6f3a5f96ea |
| files | DataController.cpp |
| diffstat | 1 files changed, 19 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/DataController.cpp Thu Feb 13 14:53:35 2014 +0100 +++ b/DataController.cpp Thu Feb 13 14:55:11 2014 +0100 @@ -7,6 +7,7 @@ #include "Exception/PermissionException.hpp" +#include <QtCore/QDebug> #include <QtCore/QTimer> #include <QtCore/QUrl> @@ -47,7 +48,7 @@ if (fs::is_directory(dir_iter->status()) ) { findFiles(QString::fromStdWString(wpath), list); } - if (fs::is_regular_file(dir_iter->status()) ) { + if (fs::is_regular_file(dir_iter->symlink_status()) ) { list << QString::fromStdWString(wpath); } } @@ -79,7 +80,10 @@ QDateTime last = QDateTime::currentDateTime(); - dblink.keepOnlyFromPrefix(dir.path(), paths); + qDebug() << "Start Delete"; + dblink.keepOnlyFromPrefix(dir.path(), paths, true); + dblink.commit(dir.path()); + qDebug() << "End Delete"; std::auto_ptr<QProgressBar> bar; @@ -429,13 +433,21 @@ void DataController::progressUpdate(int p, int max) { QString str; - if (p == 0) - str.sprintf("Progress %6.2f%%", p * 100.0 / max); - else if (p == max) { - str.sprintf("\b\b\b\b\b\b\b%6.2f%%\n", 100.0); + if (max == 0) { + str.sprintf("Progress %6.2f%%", 100.0); } else { - str.sprintf("\b\b\b\b\b\b\b%6.2f%%", p * 100.0 / max); + if (p == 0) + str.sprintf("Progress %6.2f%%", p * 100.0 / max); + else if (p == max) { + str.sprintf("\b\b\b\b\b\b\b%6.2f%%\n", 100.0); + } + else { + str.sprintf("\b\b\b\b\b\b\b%6.2f%%", p * 100.0 / max); + } + } + if (p == max) { + str+="\n"; } std::cout<<str.toStdString(); std::cout.flush();
