mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-24 21:35:47 +03:00
Fix the neon build
This commit is contained in:
parent
2e4e031795
commit
ffbf2fb6ce
2 changed files with 60 additions and 60 deletions
|
@ -77,12 +77,12 @@ bool PropagateNeonJob::updateErrorFromSession(int neon_code, ne_request* req, in
|
||||||
}
|
}
|
||||||
errorString = QString::fromUtf8( status->reason_phrase );
|
errorString = QString::fromUtf8( status->reason_phrase );
|
||||||
httpStatusCode = status->code;
|
httpStatusCode = status->code;
|
||||||
_item._httpErrorCode = httpStatusCode;
|
_item->_httpErrorCode = httpStatusCode;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
errorString = QString::fromUtf8(ne_get_error(_propagator->_session));
|
errorString = QString::fromUtf8(ne_get_error(_propagator->_session));
|
||||||
httpStatusCode = errorString.mid(0, errorString.indexOf(QChar(' '))).toInt();
|
httpStatusCode = errorString.mid(0, errorString.indexOf(QChar(' '))).toInt();
|
||||||
_item._httpErrorCode = httpStatusCode;
|
_item->_httpErrorCode = httpStatusCode;
|
||||||
if ((httpStatusCode >= 200 && httpStatusCode < 300)
|
if ((httpStatusCode >= 200 && httpStatusCode < 300)
|
||||||
|| (httpStatusCode != 0 && httpStatusCode == ignoreHttpCode)) {
|
|| (httpStatusCode != 0 && httpStatusCode == ignoreHttpCode)) {
|
||||||
// No error
|
// No error
|
||||||
|
@ -96,7 +96,7 @@ bool PropagateNeonJob::updateErrorFromSession(int neon_code, ne_request* req, in
|
||||||
errorString = QString::fromUtf8(ne_get_error(_propagator->_session));
|
errorString = QString::fromUtf8(ne_get_error(_propagator->_session));
|
||||||
// Check if we don't need to ignore that error.
|
// Check if we don't need to ignore that error.
|
||||||
httpStatusCode = errorString.mid(0, errorString.indexOf(QChar(' '))).toInt();
|
httpStatusCode = errorString.mid(0, errorString.indexOf(QChar(' '))).toInt();
|
||||||
_item._httpErrorCode = httpStatusCode;
|
_item->_httpErrorCode = httpStatusCode;
|
||||||
qDebug() << Q_FUNC_INFO << "NE_ERROR" << errorString << httpStatusCode << ignoreHttpCode;
|
qDebug() << Q_FUNC_INFO << "NE_ERROR" << errorString << httpStatusCode << ignoreHttpCode;
|
||||||
if (ignoreHttpCode && httpStatusCode == ignoreHttpCode)
|
if (ignoreHttpCode && httpStatusCode == ignoreHttpCode)
|
||||||
return false;
|
return false;
|
||||||
|
@ -123,8 +123,8 @@ bool PropagateNeonJob::updateErrorFromSession(int neon_code, ne_request* req, in
|
||||||
void UpdateMTimeAndETagJob::start()
|
void UpdateMTimeAndETagJob::start()
|
||||||
{
|
{
|
||||||
QScopedPointer<char, QScopedPointerPodDeleter> uri(
|
QScopedPointer<char, QScopedPointerPodDeleter> uri(
|
||||||
ne_path_escape((_propagator->_remoteDir + _item._file).toUtf8()));
|
ne_path_escape((_propagator->_remoteDir + _item->_file).toUtf8()));
|
||||||
if (!updateMTimeAndETag(uri.data(), _item._modtime))
|
if (!updateMTimeAndETag(uri.data(), _item->_modtime))
|
||||||
return;
|
return;
|
||||||
done(SyncFileItem::Success);
|
done(SyncFileItem::Success);
|
||||||
}
|
}
|
||||||
|
@ -134,13 +134,13 @@ void PropagateUploadFileLegacy::start()
|
||||||
if (_propagator->_abortRequested.fetchAndAddRelaxed(0))
|
if (_propagator->_abortRequested.fetchAndAddRelaxed(0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QFile file(_propagator->getFilePath(_item._file));
|
QFile file(_propagator->getFilePath(_item->_file));
|
||||||
if (!file.open(QIODevice::ReadOnly)) {
|
if (!file.open(QIODevice::ReadOnly)) {
|
||||||
done(SyncFileItem::NormalError, file.errorString());
|
done(SyncFileItem::NormalError, file.errorString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QScopedPointer<char, QScopedPointerPodDeleter> uri(
|
QScopedPointer<char, QScopedPointerPodDeleter> uri(
|
||||||
ne_path_escape((_propagator->_remoteDir + _item._file).toUtf8()));
|
ne_path_escape((_propagator->_remoteDir + _item->_file).toUtf8()));
|
||||||
|
|
||||||
int attempts = 0;
|
int attempts = 0;
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ void PropagateUploadFileLegacy::start()
|
||||||
* If the file has changed, retry.
|
* If the file has changed, retry.
|
||||||
*/
|
*/
|
||||||
qDebug() << "** PUT request to" << uri.data();
|
qDebug() << "** PUT request to" << uri.data();
|
||||||
const SyncJournalDb::UploadInfo progressInfo = _propagator->_journal->getUploadInfo(_item._file);
|
const SyncJournalDb::UploadInfo progressInfo = _propagator->_journal->getUploadInfo(_item->_file);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
Hbf_State state = HBF_SUCCESS;
|
Hbf_State state = HBF_SUCCESS;
|
||||||
|
@ -182,14 +182,14 @@ void PropagateUploadFileLegacy::start()
|
||||||
QMetaObject::invokeMethod(_propagator, "adjustTotalTransmissionSize", Qt::QueuedConnection,
|
QMetaObject::invokeMethod(_propagator, "adjustTotalTransmissionSize", Qt::QueuedConnection,
|
||||||
Q_ARG(qint64, trans->stat_size - _previousFileSize));
|
Q_ARG(qint64, trans->stat_size - _previousFileSize));
|
||||||
// update the item's values to the current from trans. hbf_splitlist does a stat
|
// update the item's values to the current from trans. hbf_splitlist does a stat
|
||||||
_item._size = trans->stat_size;
|
_item->_size = trans->stat_size;
|
||||||
_item._modtime = trans->oc_header_modtime;
|
_item->_modtime = trans->oc_header_modtime;
|
||||||
|
|
||||||
}
|
}
|
||||||
emit progress(*_item, 0);
|
emit progress(*_item, 0);
|
||||||
|
|
||||||
if (progressInfo._valid) {
|
if (progressInfo._valid) {
|
||||||
if (Utility::qDateTimeToTime_t(progressInfo._modtime) == _item._modtime) {
|
if (Utility::qDateTimeToTime_t(progressInfo._modtime) == _item->_modtime) {
|
||||||
trans->start_id = progressInfo._chunk;
|
trans->start_id = progressInfo._chunk;
|
||||||
trans->transfer_id = progressInfo._transferid;
|
trans->transfer_id = progressInfo._transferid;
|
||||||
}
|
}
|
||||||
|
@ -199,18 +199,18 @@ void PropagateUploadFileLegacy::start()
|
||||||
_lastTime.restart();
|
_lastTime.restart();
|
||||||
_lastProgress = 0;
|
_lastProgress = 0;
|
||||||
_chunked_done = 0;
|
_chunked_done = 0;
|
||||||
_chunked_total_size = _item._size;
|
_chunked_total_size = _item->_size;
|
||||||
|
|
||||||
if( state == HBF_SUCCESS ) {
|
if( state == HBF_SUCCESS ) {
|
||||||
QByteArray previousEtag;
|
QByteArray previousEtag;
|
||||||
if (!_item._etag.isEmpty() && _item._etag != "empty_etag") {
|
if (!_item->_etag.isEmpty() && _item->_etag != "empty_etag") {
|
||||||
// We add quotes because the owncloud server always add quotes around the etag, and
|
// We add quotes because the owncloud server always add quotes around the etag, and
|
||||||
// csync_owncloud.c's owncloud_file_id always strip the quotes.
|
// csync_owncloud.c's owncloud_file_id always strip the quotes.
|
||||||
previousEtag = '"' + _item._etag + '"';
|
previousEtag = '"' + _item->_etag + '"';
|
||||||
trans->previous_etag = previousEtag.data();
|
trans->previous_etag = previousEtag.data();
|
||||||
}
|
}
|
||||||
_chunked_total_size = trans->stat_size;
|
_chunked_total_size = trans->stat_size;
|
||||||
qDebug() << "About to upload " << _item._file << " (" << previousEtag << _item._size << " bytes )";
|
qDebug() << "About to upload " << _item->_file << " (" << previousEtag << _item->_size << " bytes )";
|
||||||
/* Transfer all the chunks through the HTTP session using PUT. */
|
/* Transfer all the chunks through the HTTP session using PUT. */
|
||||||
state = hbf_transfer( _propagator->_session, trans.data(), "PUT" );
|
state = hbf_transfer( _propagator->_session, trans.data(), "PUT" );
|
||||||
}
|
}
|
||||||
|
@ -218,10 +218,10 @@ void PropagateUploadFileLegacy::start()
|
||||||
// the file id should only be empty for new files up- or downloaded
|
// the file id should only be empty for new files up- or downloaded
|
||||||
QByteArray fid = hbf_transfer_file_id( trans.data() );
|
QByteArray fid = hbf_transfer_file_id( trans.data() );
|
||||||
if( !fid.isEmpty() ) {
|
if( !fid.isEmpty() ) {
|
||||||
if( !_item._fileId.isEmpty() && _item._fileId != fid ) {
|
if( !_item->_fileId.isEmpty() && _item->_fileId != fid ) {
|
||||||
qDebug() << "WARN: File ID changed!" << _item._fileId << fid;
|
qDebug() << "WARN: File ID changed!" << _item->_fileId << fid;
|
||||||
}
|
}
|
||||||
_item._fileId = fid;
|
_item->_fileId = fid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle errors. */
|
/* Handle errors. */
|
||||||
|
@ -233,7 +233,7 @@ void PropagateUploadFileLegacy::start()
|
||||||
qDebug("SOURCE file has changed during upload, retry #%d in %d seconds!", attempts, 2*attempts);
|
qDebug("SOURCE file has changed during upload, retry #%d in %d seconds!", attempts, 2*attempts);
|
||||||
Utility::sleep(2*attempts);
|
Utility::sleep(2*attempts);
|
||||||
if( _previousFileSize == 0 ) {
|
if( _previousFileSize == 0 ) {
|
||||||
_previousFileSize = _item._size;
|
_previousFileSize = _item->_size;
|
||||||
} else {
|
} else {
|
||||||
_previousFileSize = trans->stat_size;
|
_previousFileSize = trans->stat_size;
|
||||||
}
|
}
|
||||||
|
@ -247,8 +247,8 @@ void PropagateUploadFileLegacy::start()
|
||||||
done( SyncFileItem::SoftError, errMsg );
|
done( SyncFileItem::SoftError, errMsg );
|
||||||
} else {
|
} else {
|
||||||
// Other HBF error conditions.
|
// Other HBF error conditions.
|
||||||
_item._httpErrorCode = hbf_fail_http_code(trans.data());
|
_item->_httpErrorCode = hbf_fail_http_code(trans.data());
|
||||||
if(checkForProblemsWithShared(_item._httpErrorCode,
|
if(checkForProblemsWithShared(_item->_httpErrorCode,
|
||||||
tr("The file was edited locally but is part of a read only share. "
|
tr("The file was edited locally but is part of a read only share. "
|
||||||
"It is restored and your edit is in the conflict file.")))
|
"It is restored and your edit is in the conflict file.")))
|
||||||
return;
|
return;
|
||||||
|
@ -261,15 +261,15 @@ void PropagateUploadFileLegacy::start()
|
||||||
ne_set_notifier(_propagator->_session, 0, 0);
|
ne_set_notifier(_propagator->_session, 0, 0);
|
||||||
|
|
||||||
if( trans->modtime_accepted ) {
|
if( trans->modtime_accepted ) {
|
||||||
_item._etag = parseEtag(hbf_transfer_etag( trans.data() ));
|
_item->_etag = parseEtag(hbf_transfer_etag( trans.data() ));
|
||||||
} else {
|
} else {
|
||||||
if (!updateMTimeAndETag(uri.data(), trans->oc_header_modtime))
|
if (!updateMTimeAndETag(uri.data(), trans->oc_header_modtime))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_propagator->_journal->setFileRecord(SyncJournalFileRecord(*_item, _propagator->getFilePath(_item._file)));
|
_propagator->_journal->setFileRecord(SyncJournalFileRecord(*_item, _propagator->getFilePath(_item->_file)));
|
||||||
// Remove from the progress database:
|
// Remove from the progress database:
|
||||||
_propagator->_journal->setUploadInfo(_item._file, SyncJournalDb::UploadInfo());
|
_propagator->_journal->setUploadInfo(_item->_file, SyncJournalDb::UploadInfo());
|
||||||
_propagator->_journal->commit("upload file start");
|
_propagator->_journal->commit("upload file start");
|
||||||
|
|
||||||
if (hbf_validate_source_file(trans.data()) == HBF_SOURCE_FILE_CHANGE) {
|
if (hbf_validate_source_file(trans.data()) == HBF_SOURCE_FILE_CHANGE) {
|
||||||
|
@ -291,9 +291,9 @@ void PropagateUploadFileLegacy::start()
|
||||||
// Ignore this file for now.
|
// Ignore this file for now.
|
||||||
// Lets remove the file from the server (at least if it is new) as it is different
|
// Lets remove the file from the server (at least if it is new) as it is different
|
||||||
// from our file here.
|
// from our file here.
|
||||||
if( _item._instruction == CSYNC_INSTRUCTION_NEW ) {
|
if( _item->_instruction == CSYNC_INSTRUCTION_NEW ) {
|
||||||
QScopedPointer<char, QScopedPointerPodDeleter> uri(
|
QScopedPointer<char, QScopedPointerPodDeleter> uri(
|
||||||
ne_path_escape((_propagator->_remoteDir + _item._file).toUtf8()));
|
ne_path_escape((_propagator->_remoteDir + _item->_file).toUtf8()));
|
||||||
|
|
||||||
int rc = ne_delete(_propagator->_session, uri.data());
|
int rc = ne_delete(_propagator->_session, uri.data());
|
||||||
qDebug() << "Remove the invalid file from server:" << rc;
|
qDebug() << "Remove the invalid file from server:" << rc;
|
||||||
|
@ -321,7 +321,7 @@ void PropagateUploadFileLegacy::chunk_finished_cb(hbf_transfer_s *trans, int chu
|
||||||
pi._chunk = chunk + 1; // next chunk to start with
|
pi._chunk = chunk + 1; // next chunk to start with
|
||||||
pi._transferid = trans->transfer_id;
|
pi._transferid = trans->transfer_id;
|
||||||
pi._modtime = Utility::qDateTimeFromTime_t(trans->oc_header_modtime);
|
pi._modtime = Utility::qDateTimeFromTime_t(trans->oc_header_modtime);
|
||||||
that->_propagator->_journal->setUploadInfo(that->_item._file, pi);
|
that->_propagator->_journal->setUploadInfo(that->_item->_file, pi);
|
||||||
that->_propagator->_journal->commit("Upload info");
|
that->_propagator->_journal->commit("Upload info");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -332,7 +332,7 @@ void PropagateUploadFileLegacy::notify_status_cb(void* userdata, ne_session_stat
|
||||||
PropagateUploadFileLegacy* that = reinterpret_cast<PropagateUploadFileLegacy*>(userdata);
|
PropagateUploadFileLegacy* that = reinterpret_cast<PropagateUploadFileLegacy*>(userdata);
|
||||||
|
|
||||||
if (status == ne_status_sending && info->sr.total > 0) {
|
if (status == ne_status_sending && info->sr.total > 0) {
|
||||||
emit that->progress(that->_item, that->_chunked_done + info->sr.progress);
|
emit that->progress(*that->_item, that->_chunked_done + info->sr.progress);
|
||||||
|
|
||||||
that->limitBandwidth(that->_chunked_done + info->sr.progress, that->_propagator->_uploadLimit.fetchAndAddAcquire(0));
|
that->limitBandwidth(that->_chunked_done + info->sr.progress, that->_propagator->_uploadLimit.fetchAndAddAcquire(0));
|
||||||
}
|
}
|
||||||
|
@ -377,17 +377,17 @@ bool PropagateNeonJob::updateMTimeAndETag(const char* uri, time_t mtime)
|
||||||
if (updateErrorFromSession(neon_stat, req.data())) {
|
if (updateErrorFromSession(neon_stat, req.data())) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
_item._etag = get_etag_from_reply(req.data());
|
_item->_etag = get_etag_from_reply(req.data());
|
||||||
|
|
||||||
QByteArray fid = parseFileId(req.data());
|
QByteArray fid = parseFileId(req.data());
|
||||||
if( _item._fileId.isEmpty() ) {
|
if( _item->_fileId.isEmpty() ) {
|
||||||
_item._fileId = fid;
|
_item->_fileId = fid;
|
||||||
qDebug() << "FileID was empty, set it to " << _item._fileId;
|
qDebug() << "FileID was empty, set it to " << _item->_fileId;
|
||||||
} else {
|
} else {
|
||||||
if( !fid.isEmpty() && fid != _item._fileId ) {
|
if( !fid.isEmpty() && fid != _item->_fileId ) {
|
||||||
qDebug() << "WARN: FileID seems to have changed: "<< fid << _item._fileId;
|
qDebug() << "WARN: FileID seems to have changed: "<< fid << _item->_fileId;
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "FileID is " << _item._fileId;
|
qDebug() << "FileID is " << _item->_fileId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -549,7 +549,7 @@ void PropagateDownloadFileLegacy::notify_status_cb(void* userdata, ne_session_st
|
||||||
{
|
{
|
||||||
PropagateDownloadFileLegacy* that = reinterpret_cast<PropagateDownloadFileLegacy*>(userdata);
|
PropagateDownloadFileLegacy* that = reinterpret_cast<PropagateDownloadFileLegacy*>(userdata);
|
||||||
if (status == ne_status_recving && info->sr.total > 0) {
|
if (status == ne_status_recving && info->sr.total > 0) {
|
||||||
emit that->progress(that->_item, info->sr.progress );
|
emit that->progress(*that->_item, info->sr.progress );
|
||||||
|
|
||||||
that->limitBandwidth(info->sr.progress, that->_propagator->_downloadLimit.fetchAndAddAcquire(0));
|
that->limitBandwidth(info->sr.progress, that->_propagator->_downloadLimit.fetchAndAddAcquire(0));
|
||||||
}
|
}
|
||||||
|
@ -563,21 +563,21 @@ void PropagateDownloadFileLegacy::start()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// do a case clash check.
|
// do a case clash check.
|
||||||
if( _propagator->localFileNameClash(_item._file) ) {
|
if( _propagator->localFileNameClash(_item->_file) ) {
|
||||||
done( SyncFileItem::NormalError, tr("File %1 can not be downloaded because of a local file name clash!")
|
done( SyncFileItem::NormalError, tr("File %1 can not be downloaded because of a local file name clash!")
|
||||||
.arg(QDir::toNativeSeparators(_item._file)) );
|
.arg(QDir::toNativeSeparators(_item->_file)) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit progress(*_item, 0);
|
emit progress(*_item, 0);
|
||||||
|
|
||||||
QString tmpFileName;
|
QString tmpFileName;
|
||||||
const SyncJournalDb::DownloadInfo progressInfo = _propagator->_journal->getDownloadInfo(_item._file);
|
const SyncJournalDb::DownloadInfo progressInfo = _propagator->_journal->getDownloadInfo(_item->_file);
|
||||||
if (progressInfo._valid) {
|
if (progressInfo._valid) {
|
||||||
// if the etag has changed meanwhile, remove the already downloaded part.
|
// if the etag has changed meanwhile, remove the already downloaded part.
|
||||||
if (progressInfo._etag != _item._etag) {
|
if (progressInfo._etag != _item->_etag) {
|
||||||
QFile::remove(_propagator->getFilePath(progressInfo._tmpfile));
|
QFile::remove(_propagator->getFilePath(progressInfo._tmpfile));
|
||||||
_propagator->_journal->setDownloadInfo(_item._file, SyncJournalDb::DownloadInfo());
|
_propagator->_journal->setDownloadInfo(_item->_file, SyncJournalDb::DownloadInfo());
|
||||||
} else {
|
} else {
|
||||||
tmpFileName = progressInfo._tmpfile;
|
tmpFileName = progressInfo._tmpfile;
|
||||||
_expectedEtagForResume = progressInfo._etag;
|
_expectedEtagForResume = progressInfo._etag;
|
||||||
|
@ -586,7 +586,7 @@ void PropagateDownloadFileLegacy::start()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tmpFileName.isEmpty()) {
|
if (tmpFileName.isEmpty()) {
|
||||||
tmpFileName = _item._file;
|
tmpFileName = _item->_file;
|
||||||
//add a dot at the begining of the filename to hide the file.
|
//add a dot at the begining of the filename to hide the file.
|
||||||
int slashPos = tmpFileName.lastIndexOf('/');
|
int slashPos = tmpFileName.lastIndexOf('/');
|
||||||
tmpFileName.insert(slashPos+1, '.');
|
tmpFileName.insert(slashPos+1, '.');
|
||||||
|
@ -605,22 +605,22 @@ void PropagateDownloadFileLegacy::start()
|
||||||
|
|
||||||
{
|
{
|
||||||
SyncJournalDb::DownloadInfo pi;
|
SyncJournalDb::DownloadInfo pi;
|
||||||
pi._etag = _item._etag;
|
pi._etag = _item->_etag;
|
||||||
pi._tmpfile = tmpFileName;
|
pi._tmpfile = tmpFileName;
|
||||||
pi._valid = true;
|
pi._valid = true;
|
||||||
_propagator->_journal->setDownloadInfo(_item._file, pi);
|
_propagator->_journal->setDownloadInfo(_item->_file, pi);
|
||||||
_propagator->_journal->commit("download file start");
|
_propagator->_journal->commit("download file start");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_item._directDownloadUrl.isEmpty()) {
|
if (!_item->_directDownloadUrl.isEmpty()) {
|
||||||
qDebug() << Q_FUNC_INFO << "Direct download URL" << _item._directDownloadUrl << "not supported with legacy propagator, will go via ownCloud server";
|
qDebug() << Q_FUNC_INFO << "Direct download URL" << _item->_directDownloadUrl << "not supported with legacy propagator, will go via ownCloud server";
|
||||||
}
|
}
|
||||||
|
|
||||||
/* actually do the request */
|
/* actually do the request */
|
||||||
int retry = 0;
|
int retry = 0;
|
||||||
|
|
||||||
QScopedPointer<char, QScopedPointerPodDeleter> uri(
|
QScopedPointer<char, QScopedPointerPodDeleter> uri(
|
||||||
ne_path_escape((_propagator->_remoteDir + _item._file).toUtf8()));
|
ne_path_escape((_propagator->_remoteDir + _item->_file).toUtf8()));
|
||||||
|
|
||||||
do {
|
do {
|
||||||
QScopedPointer<ne_request, ScopedPointerHelpers> req(ne_request_create(_propagator->_session, "GET", uri.data()));
|
QScopedPointer<ne_request, ScopedPointerHelpers> req(ne_request_create(_propagator->_session, "GET", uri.data()));
|
||||||
|
@ -630,7 +630,7 @@ void PropagateDownloadFileLegacy::start()
|
||||||
|
|
||||||
if (tmpFile.size() > 0) {
|
if (tmpFile.size() > 0) {
|
||||||
quint64 done = tmpFile.size();
|
quint64 done = tmpFile.size();
|
||||||
if (done == _item._size) {
|
if (done == _item->_size) {
|
||||||
qDebug() << "File is already complete, no need to download";
|
qDebug() << "File is already complete, no need to download";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -666,7 +666,7 @@ void PropagateDownloadFileLegacy::start()
|
||||||
// don't keep the temporary file as the file downloaded so far is invalid
|
// don't keep the temporary file as the file downloaded so far is invalid
|
||||||
tmpFile.close();
|
tmpFile.close();
|
||||||
tmpFile.remove();
|
tmpFile.remove();
|
||||||
_propagator->_journal->setDownloadInfo(_item._file, SyncJournalDb::DownloadInfo());
|
_propagator->_journal->setDownloadInfo(_item->_file, SyncJournalDb::DownloadInfo());
|
||||||
done(SyncFileItem::SoftError, errorString);
|
done(SyncFileItem::SoftError, errorString);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -678,24 +678,24 @@ void PropagateDownloadFileLegacy::start()
|
||||||
// don't keep the temporary file if it is empty.
|
// don't keep the temporary file if it is empty.
|
||||||
tmpFile.close();
|
tmpFile.close();
|
||||||
tmpFile.remove();
|
tmpFile.remove();
|
||||||
_propagator->_journal->setDownloadInfo(_item._file, SyncJournalDb::DownloadInfo());
|
_propagator->_journal->setDownloadInfo(_item->_file, SyncJournalDb::DownloadInfo());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_item._etag = get_etag_from_reply(req.data());
|
_item->_etag = get_etag_from_reply(req.data());
|
||||||
break;
|
break;
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
tmpFile.close();
|
tmpFile.close();
|
||||||
tmpFile.flush();
|
tmpFile.flush();
|
||||||
QString fn = _propagator->getFilePath(_item._file);
|
QString fn = _propagator->getFilePath(_item->_file);
|
||||||
|
|
||||||
|
|
||||||
bool isConflict = _item._instruction == CSYNC_INSTRUCTION_CONFLICT
|
bool isConflict = _item->_instruction == CSYNC_INSTRUCTION_CONFLICT
|
||||||
&& !FileSystem::fileEquals(fn, tmpFile.fileName()); // compare the files to see if there was an actual conflict.
|
&& !FileSystem::fileEquals(fn, tmpFile.fileName()); // compare the files to see if there was an actual conflict.
|
||||||
//In case of conflict, make a backup of the old file
|
//In case of conflict, make a backup of the old file
|
||||||
if (isConflict) {
|
if (isConflict) {
|
||||||
auto conflictDate = FileSystem::fileExists(fn) ? FileSystem::getModTime(fn) : _item._modtime;
|
auto conflictDate = FileSystem::fileExists(fn) ? FileSystem::getModTime(fn) : _item->_modtime;
|
||||||
QString conflictFileName = makeConflictFileName(fn, Utility::qDateTimeFromTime_t(conflictDate));
|
QString conflictFileName = makeConflictFileName(fn, Utility::qDateTimeFromTime_t(conflictDate));
|
||||||
QString renameError;
|
QString renameError;
|
||||||
if (!FileSystem::rename(fn, conflictFileName, &renameError)) {
|
if (!FileSystem::rename(fn, conflictFileName, &renameError)) {
|
||||||
|
@ -719,10 +719,10 @@ void PropagateDownloadFileLegacy::start()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSystem::setModTime(fn, _item._modtime);
|
FileSystem::setModTime(fn, _item->_modtime);
|
||||||
|
|
||||||
_propagator->_journal->setFileRecord(SyncJournalFileRecord(*_item, fn));
|
_propagator->_journal->setFileRecord(SyncJournalFileRecord(*_item, fn));
|
||||||
_propagator->_journal->setDownloadInfo(_item._file, SyncJournalDb::DownloadInfo());
|
_propagator->_journal->setDownloadInfo(_item->_file, SyncJournalDb::DownloadInfo());
|
||||||
_propagator->_journal->commit("download file start2");
|
_propagator->_journal->commit("download file start2");
|
||||||
done(isConflict ? SyncFileItem::Conflict : SyncFileItem::Success);
|
done(isConflict ? SyncFileItem::Conflict : SyncFileItem::Success);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ protected:
|
||||||
int _httpStatusCode;
|
int _httpStatusCode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PropagateNeonJob(OwncloudPropagator* propagator, const SyncFileItem &item)
|
PropagateNeonJob(OwncloudPropagator* propagator, const SyncFileItemPtr &item)
|
||||||
: PropagateItemJob(propagator, item), _lastProgress(0), _httpStatusCode(0) {
|
: PropagateItemJob(propagator, item), _lastProgress(0), _httpStatusCode(0) {
|
||||||
moveToThread(propagator->_neonThread);
|
moveToThread(propagator->_neonThread);
|
||||||
}
|
}
|
||||||
|
@ -79,14 +79,14 @@ public:
|
||||||
class UpdateMTimeAndETagJob : public PropagateNeonJob {
|
class UpdateMTimeAndETagJob : public PropagateNeonJob {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
UpdateMTimeAndETagJob (OwncloudPropagator* propagator, const SyncFileItem& item) : PropagateNeonJob(propagator, item) {}
|
UpdateMTimeAndETagJob (OwncloudPropagator* propagator, const SyncFileItemPtr& item) : PropagateNeonJob(propagator, item) {}
|
||||||
void start() Q_DECL_OVERRIDE;
|
void start() Q_DECL_OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PropagateUploadFileLegacy: public PropagateNeonJob {
|
class PropagateUploadFileLegacy: public PropagateNeonJob {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit PropagateUploadFileLegacy(OwncloudPropagator* propagator,const SyncFileItem& item)
|
explicit PropagateUploadFileLegacy(OwncloudPropagator* propagator,const SyncFileItemPtr& item)
|
||||||
: PropagateNeonJob(propagator, item)
|
: PropagateNeonJob(propagator, item)
|
||||||
, _chunked_done(0), _chunked_total_size(0), _previousFileSize(0) {}
|
, _chunked_done(0), _chunked_total_size(0), _previousFileSize(0) {}
|
||||||
void start() Q_DECL_OVERRIDE;
|
void start() Q_DECL_OVERRIDE;
|
||||||
|
@ -116,7 +116,7 @@ private:
|
||||||
class PropagateDownloadFileLegacy: public PropagateNeonJob {
|
class PropagateDownloadFileLegacy: public PropagateNeonJob {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit PropagateDownloadFileLegacy(OwncloudPropagator* propagator,const SyncFileItem& item)
|
explicit PropagateDownloadFileLegacy(OwncloudPropagator* propagator,const SyncFileItemPtr& item)
|
||||||
: PropagateNeonJob(propagator, item), _file(0), _resumeStart(0) {}
|
: PropagateNeonJob(propagator, item), _file(0), _resumeStart(0) {}
|
||||||
void start() Q_DECL_OVERRIDE;
|
void start() Q_DECL_OVERRIDE;
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in a new issue