Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Mimetype loading optimization solution turns to mainline,Modify the introduced ABI compatibility issue #2316

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions include/dfm-base/interfaces/abstractdiriterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,6 @@ class AbstractDirIterator : public QObject
{
return {};
}
virtual void setQueryAttributes(const QString &attributes) {
queryFileAttributes = attributes;
}
virtual QString queryAttributes() const
{
return queryFileAttributes;
}
private:
QString queryFileAttributes; // isempty or * is query all file attributes
};

}
Expand Down
26 changes: 16 additions & 10 deletions src/dfm-base/file/local/localdiriterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,19 @@ FileInfoPointer LocalDirIteratorPrivate::fileInfo(const QSharedPointer<DFileInfo
} else {
isHidden = hideFileList.contains(fileName);
}

auto targetPath = dfmInfo->attribute(dfmio::DFileInfo::AttributeID::kStandardSymlinkTarget).toString();
if (FileUtils::isLocalDevice(url) && (targetPath.isEmpty() || FileUtils::isLocalDevice(QUrl::fromLocalFile(targetPath)))) {
info = QSharedPointer<SyncFileInfo>(new SyncFileInfo(url));
} else {
info = QSharedPointer<AsyncFileInfo>(new AsyncFileInfo(url, dfmInfo));
info->setExtendedAttributes(ExtInfoType::kFileIsHid, isHidden);
info.dynamicCast<AsyncFileInfo>()->cacheAsyncAttributes(q->queryAttributes());
info.dynamicCast<AsyncFileInfo>()->cacheAsyncAttributes(q->property("QueryAttributes").toString());
}

if (info) {
if (!q->queryAttributes().isEmpty() && q->queryAttributes() != "*") {
if (!q->property("QueryAttributes").toString().isEmpty()
&& q->property("QueryAttributes").toString() != "*") {
info->setExtendedAttributes(ExtInfoType::kFileNeedUpdate, true);
info->setExtendedAttributes(ExtInfoType::kFileNeedTransInfo, true);
}
Expand Down Expand Up @@ -134,6 +136,12 @@ QUrl LocalDirIterator::next()
*/
bool LocalDirIterator::hasNext() const
{
if (!d->initQuerry && d->dfmioDirIterator) {
d->initQuerry = true;
auto querry = property("QueryAttributes").toString();
if (!querry.isEmpty())
d->dfmioDirIterator->setQueryAttributes(querry);
}
if (d->dfmioDirIterator)
return d->dfmioDirIterator->hasNext();

Expand Down Expand Up @@ -269,6 +277,12 @@ bool LocalDirIterator::initIterator()

DEnumeratorFuture *LocalDirIterator::asyncIterator()
{
if (!d->initQuerry && d->dfmioDirIterator) {
d->initQuerry = true;
auto querry = property("QueryAttributes").toString();
if (!querry.isEmpty())
d->dfmioDirIterator->setQueryAttributes(querry);
}
if (d->dfmioDirIterator)
return d->dfmioDirIterator->asyncIterator();
return nullptr;
Expand All @@ -280,11 +294,3 @@ QList<FileInfoPointer> LocalDirIterator::fileInfos() const
return {};
return d->fileInfos();
}


void LocalDirIterator::setQueryAttributes(const QString &attributes)
{
if (d->dfmioDirIterator)
d->dfmioDirIterator->setQueryAttributes(attributes);
return AbstractDirIterator::setQueryAttributes(attributes);
}
3 changes: 0 additions & 3 deletions src/dfm-base/file/local/localdiriterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ class LocalDirIterator : public AbstractDirIterator
DFMIO::DEnumeratorFuture *asyncIterator();
// get all sub file's fileinfo
virtual QList<FileInfoPointer> fileInfos() const override;

// AbstractDirIterator interface
virtual void setQueryAttributes(const QString &attributes) override;
};
}

Expand Down
1 change: 1 addition & 0 deletions src/dfm-base/file/local/private/localdiriterator_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class LocalDirIteratorPrivate : public QObject
QSet<QString> hideFileList;
bool isLocalDevice = false;
bool isCdRomDevice = false;
bool initQuerry = false;
};
}
#endif // ABSTRACTDIRITERATOR_P_H
2 changes: 1 addition & 1 deletion src/dfm-base/utils/filestatisticsjob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ void FileStatisticsJob::statistcsOtherFileSystem()
qCWarning(logDFMBase) << "Failed on create dir iterator, for url:" << directory_url;
continue;
}
d->iterator->setQueryAttributes("standard::name,standard::type,standard::size,\
d->iterator->setProperty("QueryAttributes","standard::name,standard::type,standard::size,\
standard::size,standard::is-symlink,standard::symlink-target,access::*,unix::inode");
d->iteratorCanStop = true;
while (d->iterator->hasNext()) {
Expand Down
2 changes: 1 addition & 1 deletion src/dfm-base/utils/traversaldirthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void TraversalDirThread::setQueryAttributes(const QString &fileAttributes)
return;
fileInfoQueryAttributes = fileAttributes;
if (fileInfoQueryAttributes.isEmpty() && fileInfoQueryAttributes != "*")
dirIterator->setQueryAttributes(fileInfoQueryAttributes);
dirIterator->setProperty("QueryAttributes", fileInfoQueryAttributes);
}

void TraversalDirThread::run()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,7 @@ bool FileOperateBaseWorker::checkAndCopyDir(const DFileInfoPointer &fromInfo, co
}

bool self = true;
iterator->setProperty("QueryAttributes", "standard::name");
while (iterator->hasNext()) {
if (!stateCheck()) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void TraversalDirThreadManager::start()
running = true;
if (this->sortRole != dfmio::DEnumerator::SortRoleCompareFlag::kSortRoleCompareDefault
&& dirIterator->oneByOne())
dirIterator->setQueryAttributes("standard::name,standard::type,standard::size,\
dirIterator->setProperty("QueryAttributes","standard::name,standard::type,standard::size,\
standard::size,standard::is-symlink,standard::symlink-target,access::*,time::*");
auto local = dirIterator.dynamicCast<LocalDirIterator>();
if (local && local->oneByOne()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void IteratorSearcher::doSearch()
if (!iterator)
continue;

iterator->setQueryAttributes("standard::name,standard::type,standard::size,\
iterator->setProperty("QueryAttributes","standard::name,standard::type,standard::size,\
standard::size,standard::is-symlink,standard::symlink-target,access::*,time::*");

// 仅在过滤目录下进行搜索时,过滤目录下的内容才能被检索
Expand Down
Loading