Merge pull request #5174 from owncloud/fix5116_2

Better fix for #5116
This commit is contained in:
ckamm 2016-09-13 10:16:05 +02:00 committed by GitHub
commit f286493c90
4 changed files with 22 additions and 20 deletions

View file

@ -124,6 +124,11 @@ void Folder::checkLocalPath()
{
const QFileInfo fi(_definition.localPath);
_canonicalLocalPath = fi.canonicalFilePath();
if( !_canonicalLocalPath.endsWith('/') ) {
_canonicalLocalPath.append('/');
}
if( fi.isDir() && fi.isReadable() ) {
qDebug() << "Checked local path ok";
} else {
@ -161,11 +166,7 @@ QString Folder::alias() const
QString Folder::path() const
{
QString p(_definition.localPath);
if( ! p.endsWith('/') ) {
p.append('/');
}
return p;
return _canonicalLocalPath;
}
QString Folder::shortGuiLocalPath() const
@ -198,7 +199,7 @@ void Folder::setIgnoreHiddenFiles(bool ignore)
QString Folder::cleanPath()
{
QString cleanedPath = QDir::cleanPath(_definition.localPath);
QString cleanedPath = QDir::cleanPath(_canonicalLocalPath);
if(cleanedPath.length() == 3 && cleanedPath.endsWith(":/"))
cleanedPath.remove(2,1);
@ -621,6 +622,11 @@ void Folder::removeFromSettings() const
settings->remove(FolderMan::escapeAlias(_definition.alias));
}
bool Folder::isFileExcludedAbsolute(const QString& fullPath) const
{
return _engine->excludedFiles().isExcluded(fullPath, path(), _definition.ignoreHiddenFiles);
}
bool Folder::isFileExcludedRelative(const QString& relativePath) const
{
return _engine->excludedFiles().isExcluded(path() + relativePath, path(), _definition.ignoreHiddenFiles);

View file

@ -184,6 +184,11 @@ public:
/// Removes the folder from the account's settings.
void removeFromSettings() const;
/**
* Returns whether a file inside this folder should be excluded.
*/
bool isFileExcludedAbsolute(const QString& fullPath) const;
/**
* Returns whether a file inside this folder should be excluded.
*/
@ -283,6 +288,7 @@ private:
AccountStatePtr _accountState;
FolderDefinition _definition;
QString _canonicalLocalPath; // As returned with QFileInfo:canonicalFilePath. Always ends with "/"
SyncResult _syncResult;
QScopedPointer<SyncEngine> _engine;

View file

@ -41,9 +41,7 @@ FolderWatcher::FolderWatcher(const QString &root, Folder* folder)
: QObject(folder),
_folder(folder)
{
_canonicalFolderPath = QFileInfo(root).canonicalFilePath();
_d.reset(new FolderWatcherPrivate(this, _canonicalFolderPath));
_d.reset(new FolderWatcherPrivate(this, root));
_timer.start();
}
@ -57,17 +55,10 @@ bool FolderWatcher::pathIsIgnored( const QString& path )
if( !_folder ) return false;
#ifndef OWNCLOUD_TEST
QString relPath = path;
if (relPath.startsWith(_canonicalFolderPath)) {
relPath = relPath.remove(0, _canonicalFolderPath.length()+1);
if (_folder->isFileExcludedRelative(relPath)) {
qDebug() << "* Ignoring file" << relPath << "in" << _canonicalFolderPath;
return true;
}
if (_folder->isFileExcludedAbsolute(path)) {
qDebug() << "* Ignoring file" << path;
return true;
}
// there could be an odd watch event not being inside the _canonicalFolderPath
// We will just not ignore it then, who knows.
#endif
return false;
}

View file

@ -89,7 +89,6 @@ private:
QTime _timer;
QSet<QString> _lastPaths;
Folder* _folder;
QString _canonicalFolderPath;
friend class FolderWatcherPrivate;
};