Skip to content

Commit e29c64b

Browse files
committed
fix(windows/compatibility): rename automatically a file if is local
we would automatically rename a file with an invalid name do this if the newly discovered file is local and not if it is on the server (which would fail because the local file does not exists at all) Signed-off-by: Matthieu Gallien <[email protected]>
1 parent 3b8990b commit e29c64b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/libsync/discovery.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ bool ProcessDirectoryJob::handleExcluded(const QString &path, const Entries &ent
261261

262262
const auto fileName = path.mid(path.lastIndexOf('/') + 1);
263263

264+
const auto isLocal = entries.localEntry.isValid();
265+
264266
if (excluded == CSYNC_NOT_EXCLUDED) {
265267
const auto endsWithSpace = fileName.endsWith(QLatin1Char(' '));
266268
const auto startsWithSpace = fileName.startsWith(QLatin1Char(' '));
@@ -420,21 +422,21 @@ bool ProcessDirectoryJob::handleExcluded(const QString &path, const Entries &ent
420422
case CSYNC_FILE_EXCLUDE_TRAILING_SPACE:
421423
item->_errorString = tr("Filename contains trailing spaces.");
422424
item->_status = SyncFileItem::FileNameInvalid;
423-
if (!maybeRenameForWindowsCompatibility(_discoveryData->_localDir + item->_file, excluded)) {
425+
if (isLocal && !maybeRenameForWindowsCompatibility(_discoveryData->_localDir + item->_file, excluded)) {
424426
item->_errorString += QStringLiteral(" %1").arg(tr("Cannot be renamed or uploaded."));
425427
}
426428
break;
427429
case CSYNC_FILE_EXCLUDE_LEADING_SPACE:
428430
item->_errorString = tr("Filename contains leading spaces.");
429431
item->_status = SyncFileItem::FileNameInvalid;
430-
if (!maybeRenameForWindowsCompatibility(_discoveryData->_localDir + item->_file, excluded)) {
432+
if (isLocal && !maybeRenameForWindowsCompatibility(_discoveryData->_localDir + item->_file, excluded)) {
431433
item->_errorString += QStringLiteral(" %1").arg(tr("Cannot be renamed or uploaded."));
432434
}
433435
break;
434436
case CSYNC_FILE_EXCLUDE_LEADING_AND_TRAILING_SPACE:
435437
item->_errorString = tr("Filename contains leading and trailing spaces.");
436438
item->_status = SyncFileItem::FileNameInvalid;
437-
if (!maybeRenameForWindowsCompatibility(_discoveryData->_localDir + item->_file, excluded)) {
439+
if (isLocal && !maybeRenameForWindowsCompatibility(_discoveryData->_localDir + item->_file, excluded)) {
438440
item->_errorString += QStringLiteral(" %1").arg(tr("Cannot be renamed or uploaded."));
439441
}
440442
break;
@@ -476,7 +478,7 @@ bool ProcessDirectoryJob::handleExcluded(const QString &path, const Entries &ent
476478
}
477479
item->_errorString = reasonString.isEmpty() ? errorString : QStringLiteral("%1 %2").arg(errorString, reasonString);
478480
item->_status = SyncFileItem::FileNameInvalidOnServer;
479-
if (!maybeRenameForWindowsCompatibility(_discoveryData->_localDir + item->_file, excluded)) {
481+
if (isLocal && !maybeRenameForWindowsCompatibility(_discoveryData->_localDir + item->_file, excluded)) {
480482
item->_errorString += QStringLiteral(" %1").arg(tr("Cannot be renamed or uploaded."));
481483
}
482484
break;

0 commit comments

Comments
 (0)