if( fi.isDir() && fi.isReadable() ) {
qDebug() << "Checked local path ok";
} else {
- if( !FileSystem::fileExists(_definition.localPath) ) {
+ if( !FileSystem::fileExists(_definition.localPath, fi) ) {
// try to create the local dir
QDir d(_definition.localPath);
if( d.mkpath(_definition.localPath) ) {
}
}
// Check directory again
- if( !FileSystem::fileExists(_definition.localPath) ) {
+ if( !FileSystem::fileExists(_definition.localPath, fi) ) {
_syncResult.setErrorString(tr("Local folder %1 does not exist.").arg(_definition.localPath));
_syncResult.setStatus( SyncResult::SetupError );
} else if( !fi.isDir() ) {
fileNameSlash += QLatin1Char('/');
}
- if( !FileSystem::fileExists(file) ) {
+ const QFileInfo fi(file);
+ if( !FileSystem::fileExists(file, fi) ) {
qDebug() << "OO File " << file << " is not existing";
return SyncFileStatus(SyncFileStatus::STATUS_STAT_ERROR);
}
// file is ignored?
// Qt considers .lnk files symlinks on Windows so we need to work
// around that here.
- const QFileInfo fi(file);
if( fi.isSymLink()
#ifdef Q_OS_WIN
&& fi.suffix() != "lnk"
}
#endif
-bool FileSystem::fileExists(const QString& filename)
+bool FileSystem::fileExists(const QString& filename, const QFileInfo& fileInfo)
{
#ifdef Q_OS_WIN
if (isLnkFile(filename)) {
return fileExistsWin(filename);
}
#endif
- QFileInfo file(filename);
- return file.exists();
+ bool re = fileInfo.exists();
+ // if the filename is different from the filename in fileInfo, the fileInfo is
+ // not valid. There needs to be one initialised here. Otherwise the incoming
+ // fileInfo is re-used.
+ if( fileInfo.filePath() != filename ) {
+ QFileInfo myFI(filename);
+ re = myFI.exists();
+ }
+ return re;
}
#ifdef Q_OS_WIN
#include <QString>
#include <ctime>
#include <QCryptographicHash>
+#include <QFileInfo>
#include <owncloudlib.h>
* Use this over QFileInfo::exists() and QFile::exists() to avoid bugs with lnk
* files, see above.
*/
-bool OWNCLOUDSYNC_EXPORT fileExists(const QString& filename);
+bool OWNCLOUDSYNC_EXPORT fileExists(const QString& filename, const QFileInfo& = QFileInfo() );
/**
* @brief Rename the file \a originFileName to \a destinationFileName.