diff --git a/src/libsync/propagateupload.cpp b/src/libsync/propagateupload.cpp index dbea904c53..e1b4c201ac 100644 --- a/src/libsync/propagateupload.cpp +++ b/src/libsync/propagateupload.cpp @@ -329,10 +329,12 @@ void PropagateUploadFileCommon::slotStartUpload(const QByteArray &transmissionCh _item->_checksumHeader = _transmissionChecksumHeader; } - const QString fullFilePath = propagator()->getFilePath(_fileToUpload._file); + const QString fullFilePath = _fileToUpload._path; + const QString originalFilePath = propagator()->getFilePath(_item->_file); if (!FileSystem::fileExists(fullFilePath)) { - done(SyncFileItem::SoftError, tr("File Removed")); + callUnlockFolder(); + done(SyncFileItem::SoftError, tr("File Removed (start upload) %1").arg(fullFilePath)); return; } #ifdef WITH_TESTING @@ -343,9 +345,10 @@ void PropagateUploadFileCommon::slotStartUpload(const QByteArray &transmissionCh // but a potential checksum calculation could have taken some time during which the file could // have been changed again, so better check again here. - _item->_modtime = FileSystem::getModTime(fullFilePath); + _item->_modtime = FileSystem::getModTime(originalFilePath); if (prevModtime != _item->_modtime) { propagator()->_anotherSyncNeeded = true; + callUnlockFolder(); done(SyncFileItem::SoftError, tr("Local file changed during syncing. It will be resumed.")); return; } @@ -358,6 +361,7 @@ void PropagateUploadFileCommon::slotStartUpload(const QByteArray &transmissionCh // or not yet fully copied to the destination. if (fileIsStillChanging(*_item)) { propagator()->_anotherSyncNeeded = true; + callUnlockFolder(); done(SyncFileItem::SoftError, tr("Local file changed during sync.")); return; } @@ -657,6 +661,7 @@ QMap PropagateUploadFileCommon::headers() void PropagateUploadFileCommon::finalize() { + qDebug() << "Finalizing the upload. Check later if this is encrypted"; _finished = true; // Update the quota, if known @@ -674,10 +679,14 @@ void PropagateUploadFileCommon::finalize() propagator()->_journal->setUploadInfo(_item->_file, SyncJournalDb::UploadInfo()); propagator()->_journal->commit("upload file start"); + callUnlockFolder(); done(SyncFileItem::Success); +} +void PropagateUploadFileCommon::callUnlockFolder() +{ if (_uploadingEncrypted) { - qDebug() << "Encrypted file upload Successfully"; + qDebug() << "Calling Unlock"; auto *unlockJob = new UnlockEncryptFolderApiJob(propagator()->account(), _uploadEncryptedHelper->_folderId, _uploadEncryptedHelper->_folderToken, this); diff --git a/src/libsync/propagateupload.h b/src/libsync/propagateupload.h index 66e7de1558..e483f2faff 100644 --- a/src/libsync/propagateupload.h +++ b/src/libsync/propagateupload.h @@ -259,6 +259,7 @@ public: void setupEncryptedFile(const QString& path, const QString& filename, quint64 size); void setupUnencryptedFile(); void startUploadFile(); + void callUnlockFolder(); bool isLikelyFinishedQuickly() Q_DECL_OVERRIDE { return _item->_size < propagator()->smallFileSize(); } private slots: diff --git a/src/libsync/propagateuploadencrypted.cpp b/src/libsync/propagateuploadencrypted.cpp index a498b636b9..9c6ac8eac4 100644 --- a/src/libsync/propagateuploadencrypted.cpp +++ b/src/libsync/propagateuploadencrypted.cpp @@ -170,12 +170,8 @@ void PropagateUploadEncrypted::slotUpdateMetadataSuccess(const QByteArray& fileI output->deleteLater(); qDebug() << "Encrypted Info:" << outputInfo.path() << outputInfo.fileName() << outputInfo.size(); - // emit finalized(outputInfo.path(),outputInfo.fileName(),outputInfo.size()); - - auto *unlockJob = new UnlockEncryptFolderApiJob(_propagator->account(), _folderId, _folderToken, this); - connect(unlockJob, &UnlockEncryptFolderApiJob::success, []{ qDebug() << "Successfully Unlocked"; }); - connect(unlockJob, &UnlockEncryptFolderApiJob::error, []{ qDebug() << "Unlock Error"; }); - unlockJob->start(); + qDebug() << "Finalizing the upload part, now the actuall uploader will take over"; + emit finalized(outputInfo.path(),outputInfo.fileName(),outputInfo.size()); } void PropagateUploadEncrypted::slotUpdateMetadataError(const QByteArray& fileId, int httpErrorResponse)