refactor: file timestamps

This commit is contained in:
uncor3
2025-12-08 01:17:35 +00:00
parent 1c56128309
commit ad0e2d7c24
+10 -7
View File
@@ -333,22 +333,25 @@ ExportResult ExportManager::exportSingleItem(iDescriptorDevice *device,
}
}
// Clean up
outputFile.close();
ServiceManager::safeAfcFileClose(device, handle, altAfc);
// Set file times after closing the file.
if (!outputFile.setFileTime(modificationTime,
// reopen is required for timestamps
QFile reopen(outputPath);
reopen.open(QIODevice::ReadOnly);
if (modificationTime.isValid()) {
if (!reopen.setFileTime(modificationTime,
QFileDevice::FileModificationTime)) {
qWarning() << "Could not set modification time for" << outputPath;
qWarning() << "Could not set modification time for" << outputPath;
}
}
if (birthTime.isValid()) {
if (!outputFile.setFileTime(birthTime, QFileDevice::FileBirthTime)) {
// fails on linux
if (!reopen.setFileTime(birthTime, QFileDevice::FileBirthTime)) {
qWarning() << "Could not set birth time for" << outputPath;
}
}
ServiceManager::safeAfcFileClose(device, handle, altAfc);
if (totalBytes == 0) {
result.errorMessage = "No data read from device file";
outputFile.remove(); // Clean up empty file