Skip to content

Commit fb90bab

Browse files
committed
fix: simplify file timestamp attribute handling
1. Removed fallback to ctime when checking file timestamps (btime/mtime/ atime) 2. Simplified ternary operations to directly use the respective timestamp values 3. Fixed a duplicate semicolon in file initialization code The changes streamline the file timestamp attribute handling by removing redundant fallback checks to ctime. The original implementation would fall back to ctime if the primary timestamp was 0, but this behavior was unnecessary and could cause confusion. The timestamps are now directly read from their respective fields (btime, mtime, atime) without fallback. Influence: 1. Verify file creation/modification/access timestamps are correctly reported 2. Test with files that have valid timestamps in all fields 3. Check behavior with files that might have 0 values in timestamp fields 4. Verify no regression in file information display functionality fix: 简化文件时间戳属性处理 1. 移除了检查文件时间戳(btime/mtime/atime)时回退到ctime的处理 2. 简化了三元运算符,直接使用相应时间戳值 3. 修复了文件初始化代码中的重复分号问题 这些更改通过移除对ctime的冗余回退检查简化了文件时间戳属性处理。原实现会 在主时间戳为0时回退到ctime,但这种行为是不必要的且可能导致混淆。现在时间 戳直接从各自字段(btime, mtime, atime)读取而无需回退。 Influence: 1. 验证文件创建/修改/访问时间戳是否正确显示 2. 测试具有所有字段有效时间戳的文件 3. 检查时间戳字段为0时的处理行为 4. 验证文件信息显示功能没有退化 Fixes: #365719
1 parent 8187238 commit fb90bab

1 file changed

Lines changed: 8 additions & 19 deletions

File tree

src/dfm-io/dfm-io/dfileinfo.cpp

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ void DFileInfoPrivate::initNormal()
114114
return;
115115

116116
const QUrl &url = q->uri();
117-
this->gfile = DLocalHelper::createGFile(url);;
117+
this->gfile = DLocalHelper::createGFile(url);
118+
;
118119
}
119120

120121
void DFileInfoPrivate::attributeExtend(DFileInfo::MediaType type, QList<DFileInfo::AttributeExtendID> ids, DFileInfo::AttributeExtendFuncCallback callback)
@@ -304,9 +305,7 @@ QVariant DFileInfoPrivate::attributesBySelf(DFileInfo::AttributeID id)
304305
if (ret != 0)
305306
return QVariant();
306307

307-
return statxBuffer.stx_btime.tv_sec > 0
308-
? quint64(statxBuffer.stx_btime.tv_sec)
309-
: quint64(statxBuffer.stx_ctime.tv_sec);
308+
return quint64(statxBuffer.stx_btime.tv_sec);
310309
}
311310
return qulonglong(ret);
312311
}
@@ -325,9 +324,7 @@ QVariant DFileInfoPrivate::attributesBySelf(DFileInfo::AttributeID id)
325324
if (ret != 0)
326325
return QVariant();
327326

328-
return statxBuffer.stx_btime.tv_nsec > 0
329-
? statxBuffer.stx_btime.tv_nsec / 1000000
330-
: statxBuffer.stx_ctime.tv_nsec / 1000000;
327+
return statxBuffer.stx_btime.tv_nsec / 1000000;
331328
}
332329
return QVariant(ret);
333330
}
@@ -346,9 +343,7 @@ QVariant DFileInfoPrivate::attributesBySelf(DFileInfo::AttributeID id)
346343
if (ret != 0)
347344
return QVariant();
348345

349-
return statxBuffer.stx_mtime.tv_sec > 0
350-
? quint64(statxBuffer.stx_mtime.tv_sec)
351-
: quint64(statxBuffer.stx_ctime.tv_sec);
346+
return quint64(statxBuffer.stx_mtime.tv_sec);
352347
}
353348
return qulonglong(ret);
354349
}
@@ -367,9 +362,7 @@ QVariant DFileInfoPrivate::attributesBySelf(DFileInfo::AttributeID id)
367362
if (ret != 0)
368363
return QVariant();
369364

370-
return statxBuffer.stx_mtime.tv_nsec > 0
371-
? statxBuffer.stx_mtime.tv_nsec / 1000000
372-
: statxBuffer.stx_ctime.tv_nsec / 1000000;
365+
return statxBuffer.stx_mtime.tv_nsec / 1000000;
373366
}
374367
return QVariant(ret);
375368
}
@@ -388,9 +381,7 @@ QVariant DFileInfoPrivate::attributesBySelf(DFileInfo::AttributeID id)
388381
if (ret != 0)
389382
return QVariant();
390383

391-
return statxBuffer.stx_atime.tv_sec > 0
392-
? quint64(statxBuffer.stx_atime.tv_sec)
393-
: quint64(statxBuffer.stx_ctime.tv_sec);
384+
return quint64(statxBuffer.stx_atime.tv_sec);
394385
}
395386
return qulonglong(ret);
396387
}
@@ -409,9 +400,7 @@ QVariant DFileInfoPrivate::attributesBySelf(DFileInfo::AttributeID id)
409400
if (ret != 0)
410401
return QVariant();
411402

412-
return statxBuffer.stx_atime.tv_nsec > 0
413-
? statxBuffer.stx_atime.tv_nsec / 1000000
414-
: statxBuffer.stx_ctime.tv_nsec / 1000000;
403+
return statxBuffer.stx_atime.tv_nsec / 1000000;
415404
}
416405
return QVariant(ret);
417406
}

0 commit comments

Comments
 (0)