Windows filesystem sync issues?
I've run into interesting problems using Exiftool 10.10+, Qt 5.5.1 and Windows 10.
I'm creating temporary file with QTemporaryFile, write there some data, save it, wait untill it's flushed using `FlushFileBuffers()` and afterwards pass this file as arguments file for `exiftool`. Data which I'm writing there is UTF-8 encoded paths to images:
Code:
if (argumentsFile.open()) {
foreach
(const QString &line, exiftoolArguments
) { argumentsFile.write(line.toUtf8());
argumentsFile.write("\r\n");
}
}
argumentsFile.flush()
// fsync stuff here...
argumentsFile.close()
// starting exiftool with -@ argumentsFile.fileName() parameter here
// also with -charset filename=UTF8
So the problem is the following: when filenames does not contain Unicode symbols, Exiftool reads images, imports Exif metadata and everything is fine.
But when filenames contain Unicode symbols, sometimes Exiftool does not catch up them, unless I will insert `QThread::sleep(msec)` call which will make current thread to switch context and possible give ability to sync buffers for other threads (writing to harddrive).
Exiftool run from cmd line with same file always reads metadata, unless started with QProcess with the way explained before. What can be the issue?
Re: Windows filesystem sync issues?
Maybe you need to let the Qt event loop run between closing the file and starting the Exiftool process. Add a call to QCoreApplication::processEvents() and see if that helps.
Re: Windows filesystem sync issues?
Thanks. Already tried it without much success :)
Re: Windows filesystem sync issues?
Can you show how you use QProcess?
Does the QTemporaryFile live through the life time of the QProcess?
Cheers,
_
Re: Windows filesystem sync issues?
Yes, it does. For sure.
https://github.com/Ribtoks/xpiks/blo...orker.cpp#L145
Code:
QString exiftoolPath
= m_SettingsModel
->getExifToolPath
();
arguments << "-charset" << "FileName=UTF8";
arguments << "-@" << argumentsFile.fileName();
LOG_DEBUG << "Starting exiftool process:" << exiftoolPath;
m_ExiftoolProcess->start(exiftoolPath, arguments);
success = m_ExiftoolProcess->waitForFinished();
Re: Windows filesystem sync issues?
Try storing the filename before calling close().
I vaguely remember the filename becoming empty when close is being called on a temporary file.
But that was some time ago, could have been a bug or sometihg an older Qt version did.
Cheers,
_