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:
Olivier Goffart 2019-03-14 12:08:47 +01:00 committed by Kevin Ottens
parent 46bf3ed31a
commit 4346567a03
No known key found for this signature in database
GPG key ID: 074BBBCB8DECC9E2
4 changed files with 13 additions and 7 deletions

View file

@ -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();
} }
} }

View file

@ -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);

View 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();

View file

@ -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);