Verified Commit 28f362df authored by Fushan Wen's avatar Fushan Wen
Browse files

wallpapers/image: fix symlink not being found by ImageFinder

ImageFinder and PackageFinder should not ignore symlinks.

BUG: 460287
FIXED-IN: 5.26.1
parent 067a6c75
......@@ -53,25 +53,23 @@ void ImageFinder::run()
continue;
}
dir.setPath(path);
dir.setPath(target);
const QFileInfoList files = dir.entryInfoList();
for (const QFileInfo &wp : files) {
const QString t = findSymlinkTarget(wp);
const QFileInfo realwp(findSymlinkTarget(wp));
if (wp.isFile()) {
if (filterCondition(wp) && !wp.isSymLink()) {
images.append(t);
if (realwp.isFile()) {
if (filterCondition(realwp) && !realwp.isSymLink()) {
images.append(realwp.filePath());
}
} else {
const QString name = wp.fileName();
if (name.startsWith(QLatin1Char('.'))) {
} else if (realwp.isDir()) {
if (realwp.fileName().startsWith(QLatin1Char('.'))) {
continue;
}
// add this to the directories we should be looking at
m_paths.append(wp.filePath());
m_paths.append(realwp.filePath());
}
}
}
......
......@@ -34,7 +34,7 @@ void PackageFinder::run()
KPackage::Package package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Wallpaper/Images"));
const auto addPackage = [this, &package, &packages, &folders](const QString &_folderPath) {
const QString folderPath = _folderPath.endsWith(QDir::separator()) ? _folderPath : _folderPath + QDir::separator();
const QString folderPath = findSymlinkTarget(_folderPath);
if (folders.contains(folderPath)) {
// The folder has been added, return true to skip it.
......@@ -75,7 +75,7 @@ void PackageFinder::run()
const QString &path = m_paths.at(i);
const QFileInfo info(path);
if (!info.exists() || info.isFile()) {
if (!info.isDir()) {
continue;
}
......@@ -88,15 +88,13 @@ void PackageFinder::run()
const QFileInfoList files = dir.entryInfoList();
for (const QFileInfo &wp : files) {
const QString folderPath = findSymlinkTarget(wp);
if (wp.fileName().startsWith(QLatin1Char('.'))) {
continue;
}
if (!addPackage(folderPath)) {
if (!addPackage(wp.filePath())) {
// Add this to the directories we should be looking at
m_paths.append(folderPath);
m_paths.append(wp.filePath());
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment