Skip to content

Commit 492a7e4

Browse files
committed
Only check whether a file is locked before we start the upload
Fixes: #9194
1 parent 4dcace6 commit 492a7e4

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

changelog/unreleased/9194

+2
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ Therefore we checked for the locked state before we start the upload.
55
Due to a bug we checked that for each file chunk, now we only check when the upload starts and when it finished completely.
66

77
https://github.com/owncloud/client/issues/9194
8+
https://github.com/owncloud/client/pull/9264
9+
https://github.com/owncloud/client/pull/9296

src/libsync/propagateupload.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -489,10 +489,11 @@ void PropagateUploadFileCommon::slotJobDestroyed(QObject *job)
489489
// This function is used whenever there is an error occuring and jobs might be in progress
490490
void PropagateUploadFileCommon::abortWithError(SyncFileItem::Status status, const QString &error)
491491
{
492-
if (_aborting)
493-
return;
494-
abort(AbortType::Synchronous);
495-
done(status, error);
492+
qCWarning(lcPropagateUpload) << Q_FUNC_INFO << _item->_file << error;
493+
if (!_aborting) {
494+
abort(AbortType::Synchronous);
495+
done(status, error);
496+
}
496497
}
497498

498499
QMap<QByteArray, QByteArray> PropagateUploadFileCommon::headers()

src/libsync/propagateuploadv1.cpp

+11-10
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,17 @@ namespace OCC {
3838

3939
void PropagateUploadFileV1::doStartUpload()
4040
{
41-
if (!propagator()->account()->capabilities().bigfilechunkingEnabled())
42-
{
41+
const QString fileName = propagator()->fullLocalPath(_item->_file);
42+
// If the file is currently locked, we want to retry the sync
43+
// when it becomes available again.
44+
const auto lockMode = propagator()->syncOptions().requiredLockMode();
45+
if (FileSystem::isFileLocked(fileName, lockMode)) {
46+
emit propagator()->seenLockedFile(fileName, lockMode);
47+
abortWithError(SyncFileItem::SoftError, tr("%1 the file is currently in use").arg(QDir::toNativeSeparators(fileName)));
48+
return;
49+
}
50+
51+
if (!propagator()->account()->capabilities().bigfilechunkingEnabled()) {
4352
_chunkCount = 1;
4453
} else {
4554
_chunkCount = int(std::ceil(_item->_size / double(chunkSize())));
@@ -129,14 +138,6 @@ void PropagateUploadFileV1::startNextChunk()
129138
}
130139

131140
const QString fileName = propagator()->fullLocalPath(_item->_file);
132-
// If the file is currently locked, we want to retry the sync
133-
// when it becomes available again.
134-
const auto lockMode = propagator()->syncOptions().requiredLockMode();
135-
if (FileSystem::isFileLocked(fileName, lockMode)) {
136-
emit propagator()->seenLockedFile(fileName, lockMode);
137-
abortWithError(SyncFileItem::SoftError, tr("%1 the file is currently in use").arg(fileName));
138-
return;
139-
}
140141
auto device = std::unique_ptr<UploadDevice>(new UploadDevice(
141142
fileName, chunkStart, currentChunkSize, &propagator()->_bandwidthManager));
142143
if (!device->open(QIODevice::ReadOnly)) {

0 commit comments

Comments
 (0)