File indexing completed on 2024-05-12 08:50:58
0001 /* 0002 SPDX-FileCopyrightText: 2016 (c) Matthieu Gallien <matthieu_gallien@yahoo.fr> 0003 0004 SPDX-License-Identifier: LGPL-3.0-or-later 0005 */ 0006 0007 #include "localfilelisting.h" 0008 0009 #include "filescanner.h" 0010 #include "abstractfile/indexercommon.h" 0011 0012 #include <QThread> 0013 #include <QHash> 0014 #include <QStandardPaths> 0015 0016 0017 #include <algorithm> 0018 0019 class LocalFileListingPrivate 0020 { 0021 public: 0022 0023 }; 0024 0025 LocalFileListing::LocalFileListing(QObject *parent) : AbstractFileListing(parent), d(std::make_unique<LocalFileListingPrivate>()) 0026 { 0027 } 0028 0029 LocalFileListing::~LocalFileListing() 0030 = default; 0031 0032 void LocalFileListing::executeInit(QHash<QUrl, QDateTime> allFiles) 0033 { 0034 if (!isActive()) { 0035 qCDebug(orgKdeElisaIndexer()) << "LocalFileListing::executeInit is inactive"; 0036 return; 0037 } 0038 0039 qCDebug(orgKdeElisaIndexer()) << "LocalFileListing::executeInit" << "with" << allFiles.size() << "files"; 0040 AbstractFileListing::executeInit(std::move(allFiles)); 0041 } 0042 0043 void LocalFileListing::triggerRefreshOfContent() 0044 { 0045 qCDebug(orgKdeElisaIndexer()) << "LocalFileListing::triggerRefreshOfContent"; 0046 0047 if (!isActive()) { 0048 qCDebug(orgKdeElisaIndexer()) << "LocalFileListing::triggerRefreshOfContent is inactive"; 0049 return; 0050 } 0051 0052 Q_EMIT indexingStarted(); 0053 0054 qCDebug(orgKdeElisaIndexer()) << "LocalFileListing::triggerRefreshOfContent" << allRootPaths(); 0055 0056 AbstractFileListing::triggerRefreshOfContent(); 0057 0058 const auto &rootPaths = allRootPaths(); 0059 for (const auto &onePath : rootPaths) { 0060 scanDirectoryTree(onePath); 0061 } 0062 0063 setWaitEndTrackRemoval(false); 0064 0065 checkFilesToRemove(); 0066 0067 if (!waitEndTrackRemoval()) { 0068 Q_EMIT indexingFinished(); 0069 } 0070 } 0071 0072 void LocalFileListing::triggerStop() 0073 { 0074 qCDebug(orgKdeElisaIndexer()) << "LocalFileListing::triggerStop"; 0075 AbstractFileListing::triggerStop(); 0076 } 0077 0078 DataTypes::TrackDataType LocalFileListing::scanOneFile(const QUrl &scanFile, const QFileInfo &scanFileInfo, FileSystemWatchingModes watchForFileSystemChanges) 0079 { 0080 auto trackData = AbstractFileListing::scanOneFile(scanFile, scanFileInfo, watchForFileSystemChanges); 0081 0082 if (trackData.isValid()) { 0083 addCover(trackData); 0084 } else { 0085 qCDebug(orgKdeElisaIndexer()) << "LocalFileListing::scanOneFile" << scanFile << "invalid track"; 0086 } 0087 0088 return trackData; 0089 } 0090 0091 0092 #include "moc_localfilelisting.cpp"