diff options
-rw-r--r-- | changelog/unreleased/9304 | 5 | ||||
-rw-r--r-- | src/libsync/filesystem.cpp | 37 | ||||
-rw-r--r-- | src/libsync/filesystem.h | 13 | ||||
-rw-r--r-- | src/libsync/propagatedownload.cpp | 4 | ||||
-rw-r--r-- | src/libsync/propagateuploadng.cpp | 2 | ||||
-rw-r--r-- | src/libsync/propagateuploadtus.cpp | 2 | ||||
-rw-r--r-- | src/libsync/propagateuploadv1.cpp | 2 | ||||
-rw-r--r-- | src/libsync/vfs/suffix/vfs_suffix.cpp | 2 |
8 files changed, 31 insertions, 36 deletions
diff --git a/changelog/unreleased/9304 b/changelog/unreleased/9304 new file mode 100644 index 000000000..0621fd000 --- /dev/null +++ b/changelog/unreleased/9304 @@ -0,0 +1,5 @@ +Enhancement: Don't log error when checking removed file for changes + +We removed some misleading error messages from the log. + +https://github.com/owncloud/client/issues/9304 diff --git a/src/libsync/filesystem.cpp b/src/libsync/filesystem.cpp index faca9cb60..1c0f89158 100644 --- a/src/libsync/filesystem.cpp +++ b/src/libsync/filesystem.cpp @@ -89,27 +89,24 @@ bool FileSystem::setModTime(const QString &filename, time_t modTime) return true; } -bool FileSystem::fileChanged(const QString &fileName, +bool FileSystem::fileChanged(const QFileInfo &info, qint64 previousSize, time_t previousMtime) { - return getSize(fileName) != previousSize - || getModTime(fileName) != previousMtime; -} - -bool FileSystem::verifyFileUnchanged(const QString &fileName, - qint64 previousSize, - time_t previousMtime) -{ - const qint64 actualSize = getSize(fileName); - const time_t actualMtime = getModTime(fileName); + // previousMtime == -1 indicates the file does not exist + if (!info.exists() && previousMtime != -1) { + qCDebug(lcFileSystem) << info.filePath() << "was removed"; + return true; + } + const qint64 actualSize = getSize(info); + const time_t actualMtime = getModTime(info.filePath()); if (actualSize != previousSize || actualMtime != previousMtime) { - qCInfo(lcFileSystem) << "File" << fileName << "has changed:" - << "size: " << previousSize << "<->" << actualSize - << ", mtime: " << previousMtime << "<->" << actualMtime; - return false; + qCDebug(lcFileSystem) << "File" << info.filePath() << "has changed:" + << "size: " << previousSize << "<->" << actualSize + << ", mtime: " << previousMtime << "<->" << actualMtime; + return true; } - return true; + return false; } #ifdef Q_OS_WIN @@ -126,15 +123,15 @@ static qint64 getSizeWithCsync(const QString &filename) } #endif -qint64 FileSystem::getSize(const QString &filename) +qint64 FileSystem::getSize(const QFileInfo &info) { #ifdef Q_OS_WIN - if (isLnkFile(filename)) { + if (isLnkFile(info.fileName())) { // Qt handles .lnk as symlink... https://doc.qt.io/qt-5/qfileinfo.html#details - return getSizeWithCsync(filename); + return getSizeWithCsync(info.filePath()); } #endif - return QFileInfo(filename).size(); + return info.size(); } // Code inspired from Qt5's QDir::removeRecursively diff --git a/src/libsync/filesystem.h b/src/libsync/filesystem.h index f3e00f378..80b2591f7 100644 --- a/src/libsync/filesystem.h +++ b/src/libsync/filesystem.h @@ -61,7 +61,7 @@ namespace FileSystem { * Use this over QFileInfo::size() to avoid bugs with lnk files on Windows. * See https://bugreports.qt.io/browse/QTBUG-24831. */ - qint64 OWNCLOUDSYNC_EXPORT getSize(const QString &filename); + qint64 OWNCLOUDSYNC_EXPORT getSize(const QFileInfo &info); /** * @brief Retrieve a file inode with csync @@ -71,18 +71,11 @@ namespace FileSystem { /** * @brief Check if \a fileName has changed given previous size and mtime * - * Nonexisting files are covered through mtime: they have an mtime of -1. + * Nonexisting files are covered through mtime: they have an previousMtime of -1. * * @return true if the file's mtime or size are not what is expected. */ - bool OWNCLOUDSYNC_EXPORT fileChanged(const QString &fileName, - qint64 previousSize, - time_t previousMtime); - - /** - * @brief Like !fileChanged() but with verbose logging if the file *did* change. - */ - bool OWNCLOUDSYNC_EXPORT verifyFileUnchanged(const QString &fileName, + bool OWNCLOUDSYNC_EXPORT fileChanged(const QFileInfo &info, qint64 previousSize, time_t previousMtime); diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index 67085bbdc..3ba988776 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -359,7 +359,7 @@ void PropagateDownloadFile::start() // For virtual files just dehydrate or create the file and be done if (_item->_type == ItemTypeVirtualFileDehydration) { const QString fsPath = propagator()->fullLocalPath(_item->_file); - if (!FileSystem::verifyFileUnchanged(fsPath, _item->_previousSize, _item->_previousModtime)) { + if (FileSystem::fileChanged(fsPath, _item->_previousSize, _item->_previousModtime)) { propagator()->_anotherSyncNeeded = true; done(SyncFileItem::SoftError, tr("File has changed since discovery")); return; @@ -948,7 +948,7 @@ void PropagateDownloadFile::downloadFinished() // the discovery phase and now. const qint64 expectedSize = _item->_previousSize; const time_t expectedMtime = _item->_previousModtime; - if (!FileSystem::verifyFileUnchanged(fn, expectedSize, expectedMtime)) { + if (FileSystem::fileChanged(fn, expectedSize, expectedMtime)) { propagator()->_anotherSyncNeeded = true; done(SyncFileItem::SoftError, tr("File has changed since discovery")); return; diff --git a/src/libsync/propagateuploadng.cpp b/src/libsync/propagateuploadng.cpp index 9c3ac8cf4..3c02f948c 100644 --- a/src/libsync/propagateuploadng.cpp +++ b/src/libsync/propagateuploadng.cpp @@ -485,7 +485,7 @@ void PropagateUploadFileNG::slotPutFinished() } // Check whether the file changed since discovery. - if (!FileSystem::verifyFileUnchanged(fullFilePath, _item->_size, _item->_modtime)) { + if (FileSystem::fileChanged(fullFilePath, _item->_size, _item->_modtime)) { propagator()->_anotherSyncNeeded = true; if (!_finished) { abortWithError(SyncFileItem::SoftError, tr("Local file changed during sync.")); diff --git a/src/libsync/propagateuploadtus.cpp b/src/libsync/propagateuploadtus.cpp index aad0de582..5acaa794d 100644 --- a/src/libsync/propagateuploadtus.cpp +++ b/src/libsync/propagateuploadtus.cpp @@ -216,7 +216,7 @@ void PropagateUploadFileTUS::slotChunkFinished() } // Check whether the file changed since discovery. - if (!FileSystem::verifyFileUnchanged(fullFilePath, _item->_size, _item->_modtime)) { + if (FileSystem::fileChanged(fullFilePath, _item->_size, _item->_modtime)) { propagator()->_anotherSyncNeeded = true; if (!_finished) { abortWithError(SyncFileItem::SoftError, tr("Local file changed during sync.")); diff --git a/src/libsync/propagateuploadv1.cpp b/src/libsync/propagateuploadv1.cpp index 91366f6ac..93556db4e 100644 --- a/src/libsync/propagateuploadv1.cpp +++ b/src/libsync/propagateuploadv1.cpp @@ -248,7 +248,7 @@ void PropagateUploadFileV1::slotPutFinished() } // Check whether the file changed since discovery. - if (!FileSystem::verifyFileUnchanged(fullFilePath, _item->_size, _item->_modtime)) { + if (FileSystem::fileChanged(fullFilePath, _item->_size, _item->_modtime)) { propagator()->_anotherSyncNeeded = true; if (!_finished) { abortWithError(SyncFileItem::SoftError, tr("Local file changed during sync.")); diff --git a/src/libsync/vfs/suffix/vfs_suffix.cpp b/src/libsync/vfs/suffix/vfs_suffix.cpp index 223655d14..414ef01df 100644 --- a/src/libsync/vfs/suffix/vfs_suffix.cpp +++ b/src/libsync/vfs/suffix/vfs_suffix.cpp @@ -105,7 +105,7 @@ Result<void, QString> VfsSuffix::createPlaceholder(const SyncFileItem &item) QFile file(fn); if (file.exists() && file.size() > 1 - && !FileSystem::verifyFileUnchanged(fn, item._size, item._modtime)) { + && FileSystem::fileChanged(fn, item._size, item._modtime)) { return tr("Cannot create a placeholder because a file with the placeholder name already exist"); } |