mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-23 12:55:44 +03:00
Bugfix. Folder case clash conflict. Do not update parent folder record if it contains conflicted subfolers. Also fix crash with local rename.
Signed-off-by: alex-z <blackslayer4@gmail.com>
This commit is contained in:
parent
f4acb5099f
commit
d240ed9d50
4 changed files with 30 additions and 10 deletions
|
@ -1291,6 +1291,11 @@ void PropagatorCompositeJob::slotSubJobFinished(SyncFileItem::Status status)
|
|||
auto *subJob = dynamic_cast<PropagatorJob *>(sender());
|
||||
ASSERT(subJob);
|
||||
|
||||
if (!_isAnyCaseClashSubFolder) {
|
||||
if (const auto propagateDirectoryjob = qobject_cast<PropagateDirectory *>(subJob)) {
|
||||
_isAnyCaseClashSubFolder = propagateDirectoryjob->_item && propagateDirectoryjob->_item->_isCaseClashFolder;
|
||||
}
|
||||
}
|
||||
// Delete the job and remove it from our list of jobs.
|
||||
subJob->deleteLater();
|
||||
int i = _runningJobs.indexOf(subJob);
|
||||
|
@ -1496,15 +1501,16 @@ void PropagateDirectory::slotSubJobsFinished(SyncFileItem::Status status)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
const auto result = propagator()->updateMetadata(*_item);
|
||||
if (!result) {
|
||||
status = _item->_status = SyncFileItem::FatalError;
|
||||
_item->_errorString = tr("Error updating metadata: %1").arg(result.error());
|
||||
qCWarning(lcDirectory) << "Error writing to the database for file" << _item->_file << "with" << result.error();
|
||||
} else if (*result == Vfs::ConvertToPlaceholderResult::Locked) {
|
||||
_item->_status = SyncFileItem::SoftError;
|
||||
_item->_errorString = tr("File is currently in use");
|
||||
if (!_subJobs._isAnyCaseClashSubFolder) {
|
||||
const auto result = propagator()->updateMetadata(*_item);
|
||||
if (!result) {
|
||||
status = _item->_status = SyncFileItem::FatalError;
|
||||
_item->_errorString = tr("Error updating metadata: %1").arg(result.error());
|
||||
qCWarning(lcDirectory) << "Error writing to the database for file" << _item->_file << "with" << result.error();
|
||||
} else if (*result == Vfs::ConvertToPlaceholderResult::Locked) {
|
||||
_item->_status = SyncFileItem::SoftError;
|
||||
_item->_errorString = tr("File is currently in use");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -246,6 +246,7 @@ public:
|
|||
QVector<PropagatorJob *> _runningJobs;
|
||||
SyncFileItem::Status _hasError = SyncFileItem::NoStatus; // NoStatus, or NormalError / SoftError if there was an error
|
||||
quint64 _abortsCount = 0;
|
||||
bool _isAnyCaseClashSubFolder = false;
|
||||
|
||||
explicit PropagatorCompositeJob(OwncloudPropagator *propagator)
|
||||
: PropagatorJob(propagator)
|
||||
|
|
|
@ -183,6 +183,7 @@ void PropagateLocalMkdir::startLocalMkdir()
|
|||
}
|
||||
|
||||
if (Utility::fsCasePreserving() && propagator()->localFileNameClash(_item->_file)) {
|
||||
_item->_isCaseClashFolder = true;
|
||||
qCWarning(lcPropagateLocalMkdir) << "New folder to create locally already exists with different case:" << _item->_file;
|
||||
done(SyncFileItem::FileNameClash, tr("Folder %1 cannot be created because of a local file or folder name clash!").arg(newDirStr), ErrorCategory::GenericError);
|
||||
return;
|
||||
|
@ -302,7 +303,17 @@ void PropagateLocalRename::start()
|
|||
if (QString::compare(_item->_file, _item->_renameTarget, Qt::CaseInsensitive) != 0
|
||||
&& propagator()->localFileNameClash(_item->_renameTarget)) {
|
||||
|
||||
qCInfo(lcPropagateLocalRename) << "renaming a case clashed file" << _item->_file << _item->_renameTarget;
|
||||
qCInfo(lcPropagateLocalRename) << "renaming a case clashed item" << _item->_file << _item->_renameTarget;
|
||||
if (_item->isDirectory()) {
|
||||
// #HotFix
|
||||
// fix a crash (we can not create a conflicted copy for folders)
|
||||
// right now, the conflict resolution will not even work for this scenario with folders,
|
||||
// but, let's fix it step by step, this will be a second stage
|
||||
done(SyncFileItem::FileNameClash,
|
||||
tr("Folder %1 cannot be renamed because of a local file or folder name clash!").arg(_item->_file),
|
||||
ErrorCategory::GenericError);
|
||||
return;
|
||||
}
|
||||
const auto caseClashConflictResult = propagator()->createCaseClashConflict(_item, existingFile);
|
||||
if (caseClashConflictResult) {
|
||||
done(SyncFileItem::SoftError, *caseClashConflictResult, ErrorCategory::GenericError);
|
||||
|
|
|
@ -335,6 +335,8 @@ public:
|
|||
bool _isFileDropDetected = false;
|
||||
|
||||
bool _isEncryptedMetadataNeedUpdate = false;
|
||||
|
||||
bool _isCaseClashFolder = false;
|
||||
};
|
||||
|
||||
inline bool operator<(const SyncFileItemPtr &item1, const SyncFileItemPtr &item2)
|
||||
|
|
Loading…
Reference in a new issue