mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-24 05:55:59 +03:00
Resync button: Remove partial downloads too. #2445
This commit is contained in:
parent
eed91ddf46
commit
1f09a24a72
6 changed files with 65 additions and 14 deletions
|
@ -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();
|
||||
|
|
|
@ -149,6 +149,8 @@ public slots:
|
|||
void setProxyDirty(bool value);
|
||||
bool proxyDirty();
|
||||
|
||||
int slotDiscardDownloadProgress();
|
||||
int downloadInfoCount();
|
||||
int slotWipeBlacklist();
|
||||
int blackListEntryCount();
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue