Repository navigation
fix(wallpaper): refresh stale thumbnails - #207
Conversation
1. Check thumbnail freshness with Qt metadata change times. 2. Use original file times for path and file-descriptor requests. 3. Cover same-path replacements with preserved or older modification times. Log: Refresh outdated thumbnails after source replacement. Influence: Replaced wallpapers display updated thumbnails. fix(wallpaper): 修复壁纸缩略图缓存不刷新 1. 使用 Qt 文件状态变更时间判断缩略图缓存是否过期。 2. 路径和文件描述符入口均使用原图时间进行校验。 3. 覆盖同路径换图且修改时间保持不变或回退的回归场景。 Log: 原图替换后重新生成过期缩略图。 PMS: BUG-381229 Influence: 替换壁纸后显示更新的缩略图。
b3f59c2 to
3b074cb
Compare
Reviewer's GuideThe PR prevents stale wallpaper thumbnails by validating cache entries against the source file’s Qt metadata-change timestamp, applies the check consistently to path and FD requests while preserving FD ownership, and adds regression tests for same-path replacement, timestamp rollback, and regenerated image contents. Sequence diagram for timestamp-validated wallpaper cache lookupsequenceDiagram
participant Client
participant Service as WallpaperCacheService
participant Source as OriginalFile
participant Cache as CachedWallpaper
participant Scaler as ScaleImageThread
Client->>Service: GetProcessedImagePaths(originalPath, sizes)
Service->>Source: metadataChangeTime()
Service->>Cache: getCachedImagePaths(originalPath, sizes, sourceChangeTime)
Cache->>Cache: findCachedImagePaths(pathMd5, sizes, sourceChangeTime)
Cache->>Cache: metadataChangeTime() on cached image
alt cache timestamp is current
Cache-->>Service: cached paths
Service-->>Client: cached paths
else cache is missing or stale
Cache->>Scaler: generate thumbnails
Scaler-->>Cache: processed paths
Cache-->>Service: regenerated paths
Service-->>Client: regenerated paths
end
Sequence diagram for FD-based wallpaper cache refreshsequenceDiagram
participant Client
participant Service as WallpaperCacheService
participant FD as SourceFileDescriptor
participant Cache as CachedWallpaper
participant Scaler as ScaleImageThread
Client->>Service: GetProcessedImagePathByFd(fd, imagePathMd5, sizes)
Service->>FD: open(ReadOnly, DontCloseHandle)
Service->>FD: fileTime(FileMetadataChangeTime)
Service->>Cache: findCachedImagePaths(imagePathMd5, sizes, sourceChangeTime)
alt cache is current
Cache-->>Service: cached paths
Service-->>Client: cached paths
else cache is missing or stale
Service->>Scaler: import and generate thumbnails
Scaler-->>Service: processed paths
Service->>Cache: getCachedImagePaths(destinationPath, sizes, true, sourceChangeTime)
Cache-->>Service: refreshed paths
Service-->>Client: refreshed paths
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mhduiy, yixinshark 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 |
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: [] 2. 代码质量 ✅评价: 代码结构清晰,存在少量测试健壮性改进空间 ✅ 通过 潜在问题: 建议: ['在 findCachedImagePaths 中,将过期检测的 return {} 改为 continue,仅跳过过期条目,保留其他有效缓存路径', '在测试开头添加 QVERIFY(dir.isValid()) 以确保临时目录创建成功', '在测试函数末尾添加 worker.stopThread() 和 QVERIFY(worker.wait(5000)),与其他测试保持一致', '在测试 FD 路径中使用 QVERIFY2 替代静默返回空列表,提供明确的失败诊断信息'] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: ['findCachedImagePaths 使用 continue 替代 return {} 可避免多 size 场景下的不必要重新生成'] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例// cachedwallpaper.cpp - findCachedImagePaths 建议改用 continue
QStringList CachedWallpaper::findCachedImagePaths(const QString &pathMd5, const QList<QSize> &sizes,
const QDateTime &sourceChangeTime) const
{
QStringList results;
const auto it = m_cachedImages.constFind(pathMd5);
if (it == m_cachedImages.constEnd())
return results;
for (const QString &path : it.value()) {
const QFileInfo info(path);
if (path.isEmpty() || !info.isFile() || !info.isReadable() || info.size() == 0)
continue; // 跳过无效条目,保留其他有效缓存
const QDateTime cacheChangeTime = info.metadataChangeTime();
if (!sourceChangeTime.isValid() || !cacheChangeTime.isValid() || cacheChangeTime < sourceChangeTime)
continue; // 跳过过期条目,保留其他有效缓存
results.append(path);
}
return results;
}
// test_wallpaper_cache_unit.cpp - 建议补充验证和清理
void replacedThumbnailRefreshes()
{
QFETCH(bool, useFd);
QTemporaryDir dir;
QVERIFY(dir.isValid()); // 确保临时目录创建成功
// ... test body ...
worker.stopThread(); // 显式停止 worker
QVERIFY(worker.wait(5000)); // 确保线程退出
}本报告由 AI 代码审查工具自动生成 |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
PMS: BUG-381229
修改
验证
边界
Summary by Sourcery
Invalidate stale wallpaper thumbnails based on source file changes and regenerate them on demand.
Bug Fixes:
Enhancements:
Tests: