Skip to content

Commit e17f91c

Browse files
committed
fix: improve icon file synchronization logic
1. Add target file hash verification before copying icons 2. Remove corrupted cache entries when target file has been modified externally 3. Prevent overwriting files that were changed by other processes 4. Maintain cache integrity by detecting external modifications fix: 改进图标文件同步逻辑 1. 在复制图标前添加目标文件哈希验证 2. 当目标文件被外部修改时移除损坏的缓存条目 3. 防止覆盖被其他进程更改的文件 4. 通过检测外部修改来维护缓存完整性
1 parent 87f9f01 commit e17f91c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tools/xdgicon2dci/main.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,13 @@ void XDGIcon2Dci::copyDciFiles(const QString &fromDir, QMap<QString, QString> &r
260260
bool needCopy = false;
261261
if (!QFile::exists(targetPath)) {
262262
needCopy = true;
263-
} else if (recordCache.contains(iconName)
264-
&& recordCache.value(iconName) != newFileHash) {
265-
needCopy = true;
263+
} else if (recordCache.contains(iconName)) {
264+
QString targetFileHash = getFileHash(targetPath);
265+
if (targetFileHash != recordCache.value(iconName)) { // 记录的hash和目前已经存在文件hash不一致,说明目标文件已经被其他操作修改,不再跟踪
266+
recordCache.remove(iconName);
267+
} else if (recordCache.value(iconName) != newFileHash) {
268+
needCopy = true;
269+
}
266270
}
267271

268272
if (needCopy) {

0 commit comments

Comments
 (0)