Skip to content

Commit

Permalink
feat: Mimetype loading optimization solution turns to mainline,Modify…
Browse files Browse the repository at this point in the history
… the introduced ABI compatibility issue

Modify the introduced ABI compatibility issue

Log: Mimetype loading optimization solution turns to mainline,Modify the introduced ABI compatibility issue
Task: https://pms.uniontech.com/task-view-361145.html
  • Loading branch information
liyigang1 authored and Johnson-zs committed Nov 22, 2024
1 parent 4b370d4 commit be0efbb
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 25 deletions.
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
25 changes: 16 additions & 9 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,10 +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 @@ -515,7 +515,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 @@ -719,6 +719,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

0 comments on commit be0efbb

Please sign in to comment.