| 1229 | } |
| 1230 | |
| 1231 | RelevantDir Application::findDirectory(const QString &dirIdentifier) |
| 1232 | { |
| 1233 | int dummy; |
| 1234 | RelevantDir relevantDir; |
| 1235 | |
| 1236 | // check whether the specified identifier is a known Syncthing folder (matches a folder ID or label) |
| 1237 | const auto isRelative = QDir::isRelativePath(dirIdentifier); |
| 1238 | if (isRelative) { // check this only for relative paths, otherwise e.g. "/foo" would rescan "foo" in the first Syncthing folder with an empty label |
| 1239 | // check for first slash to allow paths like "docs-misc/Notizen.txt" where "Notizen.txt" is an item within the Syncthing folder labeled "docs-misc" |
| 1240 | auto firstSlash = dirIdentifier.indexOf(QChar('/')); |
| 1241 | relevantDir.dirObj = m_connection.findDirInfoConsideringLabels(firstSlash >= 0 ? dirIdentifier.mid(0, firstSlash) : dirIdentifier, dummy); |
| 1242 | if (relevantDir) { |
| 1243 | if (firstSlash >= 0) { |
| 1244 | relevantDir.subDir = dirIdentifier.mid(firstSlash + 1); |
| 1245 | } |
| 1246 | return relevantDir; |
| 1247 | } |
| 1248 | } |
| 1249 | |
| 1250 | // check whether the specified identifier is an absolute or relative path of an item inside a known Syncthing directory |
| 1251 | relevantDir.dirObj |
| 1252 | = m_connection.findDirInfoByPath(isRelative ? QDir::currentPath() % QChar('/') % dirIdentifier : dirIdentifier, relevantDir.subDir, dummy); |
| 1253 | if (relevantDir) { |
| 1254 | return relevantDir; |
| 1255 | } |
| 1256 | |
| 1257 | cerr << Phrases::Warning << "Specified folder \"" << dirIdentifier.toLocal8Bit().data() << "\" is no Syncthing folder (or not part of any)." |
| 1258 | << Phrases::End; |
| 1259 | return relevantDir; |
| 1260 | } |
| 1261 | |
| 1262 | void RelevantDir::notifyAboutRescan() const |
| 1263 | { |
nothing calls this directly
no test coverage detected