-
Notifications
You must be signed in to change notification settings - Fork 28
Merge v20 and v25 branch codes, merge branches into one #238
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
Conversation
- Introduced DLocalHelper::createGFile to centralize GFile creation from QUrl or path, replacing direct g_file_new_for_uri/g_file_new_for_path calls throughout the codebase. - Updated DFile, DFileInfo, DEnumerator, DOperator, DWatcher, DFMUtils, and related tools to use the new helper for improved consistency and maintainability. - Added DFMUtils::isUnvalidCodecByPath to check for invalid codec in file paths, and integrated this check in DEnumerator and DLocalHelper to set userInfo in QUrl when necessary. - Improved symlink handling in DLocalHelper::createSortFileInfo to use fromLocal8Bit for target paths. - Enhanced robustness and code clarity in file operations and path handling. Log: Refactor GFile creation and add codec validation for file paths Bug: https://pms.uniontech.com//bug-view-315953.html
- Introduced OperatorsFileUtils singleton class with delayRemoveCopyingFile method to delay the removal of copying file URLs by 500ms. - Updated FileOperateBaseWorker to use OperatorsFileUtils::delayRemoveCopyingFile instead of direct FileUtils::removeCopyingFileUrl calls. - Enhances safety and reliability of file operations by preventing premature removal of file URLs. Log: add OperatorsFileUtils for delayed removal of copying file URLs Bug: https://pms.uniontech.com//bug-view-315953.html
- Add symlinkTarget() and resolveSymlink() helpers to resolve symlink chains and detect cycles - Add fileSizeByEnt() to correctly determine file size for symlinks, including chained symlinks - Update compareBySize() to use fileSizeByEnt() for accurate sorting - Refactor createSortFileInfo() to use resolveSymlink() for symlink targets and update file size and isDir accordingly - Fix stat usage to handle UTF-8 paths and improve symlink resolution logic - Ensure isDir and isFile are set correctly for symlinks and their targets These changes improve the accuracy of file size and type detection for symlinks, especially when sorting or displaying file information. Log: improve symlink handling and file size calculation in DLocalHelper Bug:
- Add initEnumerator demo mode to showcase different enumeration methods - Implement better error handling and logging in DEnumerator - Fix potential memory leaks in filePath and sortFileInfoList functions - Update dfm-list tool to include demo mode for testing new features Log: feat(denumerator): add initEnumerator demo and improve error handling Bug: https://pms.uniontech.com/bug-view-333909.html
…evelop/eagle-20250617 to master - Use DLocalHelper::createGFile with proper spacing in dfm-copy3 for code style consistency. - Update DLocalHelper::fileSizeByEnt to return -1 for directories, avoiding misuse of directory st_size as a regular file size. - Refactor DEnumeratorPrivate::hasNext to build nextUrl via buildUrl, improving robustness and correctness of path construction. Log: improve path handling and file size detection in dfm-io, merge develop/eagle-20250617 to master
deepin pr auto review我来对这段代码进行详细审查:
// 在 DLocalHelper::createGFile 中添加空指针检查
GFile *DLocalHelper::createGFile(const QUrl &uri)
{
if (!uri.isValid()) {
qWarning() << "Invalid URI provided";
return nullptr;
}
QString path = uri.userInfo().isEmpty() || !uri.userInfo().startsWith("originPath::") ?
QString() : uri.userInfo().replace("originPath::", "");
return path.isEmpty() ?
g_file_new_for_uri(uri.toString().toLocal8Bit().data()) :
g_file_new_for_path(path.toLocal8Bit().data());
}
// 优化 DEnumeratorPrivate::filePath 的内存管理
char *DEnumeratorPrivate::filePath(const QUrl &url)
{
if (!url.isValid()) {
qWarning() << "Invalid URL provided";
return nullptr;
}
QString path;
if (url.userInfo().startsWith("originPath::")) {
path = url.userInfo().replace("originPath::", "");
} else {
path = url.path();
if (path != "/" && path.endsWith("/"))
path.chop(1);
}
return strdup(path.toUtf8().constData());
}
// 优化 buildUrl 函数的字符串拼接
QUrl DEnumeratorPrivate::buildUrl(const QUrl &url, const char *fileName)
{
if (!fileName) {
qWarning() << "Invalid file name provided";
return QUrl();
}
const QString fileNameStr = QString::fromUtf8(fileName);
QString path = url.path();
if (path != "/")
path += QLatin1Char('/');
path += fileNameStr;
QUrl nextUrl = QUrl::fromLocalFile(path);
if (url.userInfo().startsWith("originPath::")) {
nextUrl.setUserInfo(url.userInfo() % QLatin1Char('/') % fileNameStr);
} else if (DFMUtils::isInvalidCodecByPath(fileName)) {
QString orgPath = url.path();
if (orgPath != "/")
orgPath += QLatin1Char('/');
orgPath += fileNameStr;
nextUrl.setUserInfo(QLatin1String("originPath::") % orgPath);
}
return nextUrl;
}
这些改进可以提高代码的健壮性、性能和可维护性。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Johnson-zs, liyigang1 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Merge v20 and v25 branch codes, merge branches into one