mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 13:35:58 +03:00
Async Poll: keep the size in the database
This was not required with 2.5 because a size of 0 was ignorted when comparing size by the csync updater, to be compatible with very old version of the database. But the we discovery will still think the file is changed if the database contains a size of 0
This commit is contained in:
parent
46bf3ed31a
commit
4346567a03
4 changed files with 13 additions and 7 deletions
|
@ -442,12 +442,13 @@ bool SyncJournalDb::checkConnect()
|
||||||
return sqlFail("Create table blacklist", createQuery);
|
return sqlFail("Create table blacklist", createQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
createQuery.prepare("CREATE TABLE IF NOT EXISTS poll("
|
createQuery.prepare("CREATE TABLE IF NOT EXISTS async_poll("
|
||||||
"path VARCHAR(4096),"
|
"path VARCHAR(4096),"
|
||||||
"modtime INTEGER(8),"
|
"modtime INTEGER(8),"
|
||||||
|
"filesize BIGINT,"
|
||||||
"pollpath VARCHAR(4096));");
|
"pollpath VARCHAR(4096));");
|
||||||
if (!createQuery.exec()) {
|
if (!createQuery.exec()) {
|
||||||
return sqlFail("Create table poll", createQuery);
|
return sqlFail("Create table async_poll", createQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the selectivesync table.
|
// create the selectivesync table.
|
||||||
|
@ -1722,7 +1723,7 @@ QVector<SyncJournalDb::PollInfo> SyncJournalDb::getPollInfos()
|
||||||
if (!checkConnect())
|
if (!checkConnect())
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
SqlQuery query("SELECT path, modtime, pollpath FROM poll", _db);
|
SqlQuery query("SELECT path, modtime, filesize, pollpath FROM async_poll", _db);
|
||||||
|
|
||||||
if (!query.exec()) {
|
if (!query.exec()) {
|
||||||
return res;
|
return res;
|
||||||
|
@ -1732,7 +1733,8 @@ QVector<SyncJournalDb::PollInfo> SyncJournalDb::getPollInfos()
|
||||||
PollInfo info;
|
PollInfo info;
|
||||||
info._file = query.stringValue(0);
|
info._file = query.stringValue(0);
|
||||||
info._modtime = query.int64Value(1);
|
info._modtime = query.int64Value(1);
|
||||||
info._url = query.stringValue(2);
|
info._fileSize = query.int64Value(2);
|
||||||
|
info._url = query.stringValue(3);
|
||||||
res.append(info);
|
res.append(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1749,14 +1751,15 @@ void SyncJournalDb::setPollInfo(const SyncJournalDb::PollInfo &info)
|
||||||
|
|
||||||
if (info._url.isEmpty()) {
|
if (info._url.isEmpty()) {
|
||||||
qCDebug(lcDb) << "Deleting Poll job" << info._file;
|
qCDebug(lcDb) << "Deleting Poll job" << info._file;
|
||||||
SqlQuery query("DELETE FROM poll WHERE path=?", _db);
|
SqlQuery query("DELETE FROM async_poll WHERE path=?", _db);
|
||||||
query.bindValue(1, info._file);
|
query.bindValue(1, info._file);
|
||||||
query.exec();
|
query.exec();
|
||||||
} else {
|
} else {
|
||||||
SqlQuery query("INSERT OR REPLACE INTO poll (path, modtime, pollpath) VALUES( ? , ? , ? )", _db);
|
SqlQuery query("INSERT OR REPLACE INTO async_poll (path, modtime, filesize, pollpath) VALUES( ? , ? , ? , ? )", _db);
|
||||||
query.bindValue(1, info._file);
|
query.bindValue(1, info._file);
|
||||||
query.bindValue(2, info._modtime);
|
query.bindValue(2, info._modtime);
|
||||||
query.bindValue(3, info._url);
|
query.bindValue(3, info._fileSize);
|
||||||
|
query.bindValue(4, info._url);
|
||||||
query.exec();
|
query.exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,6 +114,7 @@ public:
|
||||||
QString _file; // The relative path of a file
|
QString _file; // The relative path of a file
|
||||||
QString _url; // the poll url. (This pollinfo is invalid if _url is empty)
|
QString _url; // the poll url. (This pollinfo is invalid if _url is empty)
|
||||||
qint64 _modtime; // The modtime of the file being uploaded
|
qint64 _modtime; // The modtime of the file being uploaded
|
||||||
|
qint64 _fileSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
DownloadInfo getDownloadInfo(const QString &file);
|
DownloadInfo getDownloadInfo(const QString &file);
|
||||||
|
|
|
@ -1008,6 +1008,7 @@ void CleanupPollsJob::start()
|
||||||
SyncFileItemPtr item(new SyncFileItem);
|
SyncFileItemPtr item(new SyncFileItem);
|
||||||
item->_file = info._file;
|
item->_file = info._file;
|
||||||
item->_modtime = info._modtime;
|
item->_modtime = info._modtime;
|
||||||
|
item->_size = info._fileSize;
|
||||||
auto *job = new PollJob(_account, info._url, item, _journal, _localPath, this);
|
auto *job = new PollJob(_account, info._url, item, _journal, _localPath, this);
|
||||||
connect(job, &PollJob::finishedSignal, this, &CleanupPollsJob::slotPollFinished);
|
connect(job, &PollJob::finishedSignal, this, &CleanupPollsJob::slotPollFinished);
|
||||||
job->start();
|
job->start();
|
||||||
|
|
|
@ -592,6 +592,7 @@ void PropagateUploadFileCommon::startPollJob(const QString &path)
|
||||||
info._file = _item->_file;
|
info._file = _item->_file;
|
||||||
info._url = path;
|
info._url = path;
|
||||||
info._modtime = _item->_modtime;
|
info._modtime = _item->_modtime;
|
||||||
|
info._fileSize = _item->_size;
|
||||||
propagator()->_journal->setPollInfo(info);
|
propagator()->_journal->setPollInfo(info);
|
||||||
propagator()->_journal->commit("add poll info");
|
propagator()->_journal->commit("add poll info");
|
||||||
propagator()->_activeJobList.append(this);
|
propagator()->_activeJobList.append(this);
|
||||||
|
|
Loading…
Reference in a new issue