mirror of
https://github.com/iDescriptor/iDescriptor.git
synced 2026-06-21 19:35:49 +08:00
refactor: file timestamps
This commit is contained in:
+10
-7
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user