[Pkg-owncloud-commits] [owncloud-client] 54/69: Resync button: Remove partial downloads too. #2445

Sandro Knauß hefee-guest at moszumanska.debian.org
Fri Nov 7 19:41:11 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 1f09a24a72c9dc0d70a4a479e0d9ea0c2d49185f
Author: Christian Kamm <kamm at incasoftware.de>
Date:   Wed Nov 5 14:52:57 2014 +0100

    Resync button: Remove partial downloads too. #2445
---
 src/mirall/folder.cpp         | 20 ++++++++++++++++++++
 src/mirall/folder.h           |  2 ++
 src/mirall/protocolwidget.cpp | 34 ++++++++++++++++++++++------------
 src/mirall/protocolwidget.h   |  4 ++--
 src/mirall/syncjournaldb.cpp  | 18 ++++++++++++++++++
 src/mirall/syncjournaldb.h    |  1 +
 6 files changed, 65 insertions(+), 14 deletions(-)

diff --git a/src/mirall/folder.cpp b/src/mirall/folder.cpp
index 4ce9fa2..de1f3a2 100644
--- a/src/mirall/folder.cpp
+++ b/src/mirall/folder.cpp
@@ -506,6 +506,26 @@ void Folder::createGuiLog( const QString& filename, SyncFileStatus status, int c
     }
 }
 
+int Folder::slotDiscardDownloadProgress()
+{
+    // Delete from journal and from filesystem.
+    QDir folderpath(_path);
+    QSet<QString> keep_nothing;
+    const QVector<SyncJournalDb::DownloadInfo> deleted_infos =
+            _journal.getAndDeleteStaleDownloadInfos(keep_nothing);
+    foreach (const SyncJournalDb::DownloadInfo & deleted_info, deleted_infos) {
+        const QString tmppath = folderpath.filePath(deleted_info._tmpfile);
+        qDebug() << "Deleting temporary file: " << tmppath;
+        QFile::remove(tmppath);
+    }
+    return deleted_infos.size();
+}
+
+int Folder::downloadInfoCount()
+{
+    return _journal.downloadInfoCount();
+}
+
 int Folder::blackListEntryCount()
 {
     return _journal.blackListEntryCount();
diff --git a/src/mirall/folder.h b/src/mirall/folder.h
index b5507db..01b2b0b 100644
--- a/src/mirall/folder.h
+++ b/src/mirall/folder.h
@@ -149,6 +149,8 @@ public slots:
       void setProxyDirty(bool value);
       bool proxyDirty();
 
+      int slotDiscardDownloadProgress();
+      int downloadInfoCount();
       int slotWipeBlacklist();
       int blackListEntryCount();
 
diff --git a/src/mirall/protocolwidget.cpp b/src/mirall/protocolwidget.cpp
index 0e05731..e469b3c 100644
--- a/src/mirall/protocolwidget.cpp
+++ b/src/mirall/protocolwidget.cpp
@@ -65,9 +65,9 @@ ProtocolWidget::ProtocolWidget(QWidget *parent) :
 
     connect(this, SIGNAL(guiLog(QString,QString)), Logger::instance(), SIGNAL(guiLog(QString,QString)));
 
-    _clearBlacklistBtn = _ui->_dialogButtonBox->addButton(tr("Retry Sync"), QDialogButtonBox::ActionRole);
-    _clearBlacklistBtn->setEnabled(false);
-    connect(_clearBlacklistBtn, SIGNAL(clicked()), SLOT(slotClearBlacklist()));
+    _retrySyncBtn = _ui->_dialogButtonBox->addButton(tr("Retry Sync"), QDialogButtonBox::ActionRole);
+    _retrySyncBtn->setEnabled(false);
+    connect(_retrySyncBtn, SIGNAL(clicked()), SLOT(slotRetrySync()));
 
     _copyBtn = _ui->_dialogButtonBox->addButton(tr("Copy"), QDialogButtonBox::ActionRole);
     _copyBtn->setToolTip( tr("Copy the activity list to the clipboard."));
@@ -118,7 +118,7 @@ void ProtocolWidget::copyToClipboard()
     emit guiLog(tr("Copied to clipboard"), tr("The sync status has been copied to the clipboard."));
 }
 
-void ProtocolWidget::slotClearBlacklist()
+void ProtocolWidget::slotRetrySync()
 {
     FolderMan *folderMan = FolderMan::instance();
 
@@ -126,7 +126,12 @@ void ProtocolWidget::slotClearBlacklist()
 
     foreach( Folder *f, folders ) {
         int num = f->slotWipeBlacklist();
-        qDebug() << num << "entries were removed from"<< f->alias() << "blacklist";
+        qDebug() << num << "entries were removed from"
+                 << f->alias() << "blacklist";
+
+        num = f->slotDiscardDownloadProgress();
+        qDebug() << num << "temporary files with partial downloads"
+                 << "were removed from" << f->alias();
     }
 
     folderMan->slotScheduleAllFolders();
@@ -247,18 +252,23 @@ void ProtocolWidget::computeResyncButtonEnabled()
     FolderMan *folderMan = FolderMan::instance();
     Folder::Map folders = folderMan->map();
 
-    int cnt = 0;
+    int blacklist_cnt = 0;
+    int downloads_cnt = 0;
     foreach( Folder *f, folders ) {
-        cnt += f->blackListEntryCount();
+        blacklist_cnt += f->blackListEntryCount();
+        downloads_cnt += f->downloadInfoCount();
     }
 
-    QString t = tr("Currently no files are ignored because of previous errors.");
-    if(cnt > 0) {
-        t = tr("%n files are ignored because of previous errors.\n Try to sync these again.", 0, cnt);
+    QString t = tr("Currently no files are ignored because of previous errors and no downloads are in progress.");
+    bool enabled = blacklist_cnt > 0 || downloads_cnt > 0;
+    if (enabled) {
+        t =   tr("%n files are ignored because of previous errors.\n", 0, blacklist_cnt)
+            + tr("%n files are partially downloaded.\n", 0, downloads_cnt)
+            + tr("Try to sync these again.");
     }
 
-    _clearBlacklistBtn->setEnabled(cnt > 0);
-    _clearBlacklistBtn->setToolTip(t);
+    _retrySyncBtn->setEnabled(enabled);
+    _retrySyncBtn->setToolTip(t);
 
 }
 
diff --git a/src/mirall/protocolwidget.h b/src/mirall/protocolwidget.h
index 244f4e9..68e11a1 100644
--- a/src/mirall/protocolwidget.h
+++ b/src/mirall/protocolwidget.h
@@ -47,7 +47,7 @@ public slots:
 
 protected slots:
     void copyToClipboard();
-    void slotClearBlacklist();
+    void slotRetrySync();
 
 signals:
     void guiLog(const QString&, const QString&);
@@ -65,7 +65,7 @@ private:
 
     const int IgnoredIndicatorRole;
     Ui::ProtocolWidget *_ui;
-    QPushButton *_clearBlacklistBtn;
+    QPushButton *_retrySyncBtn;
     QPushButton *_copyBtn;
 };
 
diff --git a/src/mirall/syncjournaldb.cpp b/src/mirall/syncjournaldb.cpp
index bdd6016..fca1c9e 100644
--- a/src/mirall/syncjournaldb.cpp
+++ b/src/mirall/syncjournaldb.cpp
@@ -807,6 +807,24 @@ QVector<SyncJournalDb::DownloadInfo> SyncJournalDb::getAndDeleteStaleDownloadInf
     return deleted_entries;
 }
 
+int SyncJournalDb::downloadInfoCount()
+{
+    int re = 0;
+
+    QMutexLocker locker(&_mutex);
+    if( checkConnect() ) {
+        SqlQuery query("SELECT count(*) FROM downloadinfo", _db);
+
+        if( ! query.exec() ) {
+            sqlFail("Count number of downloadinfo entries failed", query);
+        }
+        if( query.next() ) {
+            re = query.intValue(0);
+        }
+    }
+    return re;
+}
+
 SyncJournalDb::UploadInfo SyncJournalDb::getUploadInfo(const QString& file)
 {
     QMutexLocker locker(&_mutex);
diff --git a/src/mirall/syncjournaldb.h b/src/mirall/syncjournaldb.h
index d434563..2dc3f6a 100644
--- a/src/mirall/syncjournaldb.h
+++ b/src/mirall/syncjournaldb.h
@@ -72,6 +72,7 @@ public:
     DownloadInfo getDownloadInfo(const QString &file);
     void setDownloadInfo(const QString &file, const DownloadInfo &i);
     QVector<DownloadInfo> getAndDeleteStaleDownloadInfos(const QSet<QString>& keep);
+    int downloadInfoCount();
 
     UploadInfo getUploadInfo(const QString &file);
     void setUploadInfo(const QString &file, const UploadInfo &i);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list