[CSE] Assorted fixes

- Unlock the folder even on error
- Use the correct name of the file for upload
This commit is contained in:
Tomaz Canabrava 2017-12-24 16:30:39 +01:00
parent 60ef722b60
commit 06c34ed617
3 changed files with 16 additions and 10 deletions

View File

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

View File

@ -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:

View File

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