PDA

View Full Version : Windows filesystem sync issues?



ribtoks
16th March 2016, 15:12
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:


if (argumentsFile.open()) {
QStringList exiftoolArguments = createArgumentsList();
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?

d_stranz
16th March 2016, 17:49
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.

ribtoks
16th March 2016, 17:50
Thanks. Already tried it without much success :)

anda_skoa
16th March 2016, 20:33
Can you show how you use QProcess?

Does the QTemporaryFile live through the life time of the QProcess?

Cheers,
_

ribtoks
16th March 2016, 20:36
Yes, it does. For sure.
https://github.com/Ribtoks/xpiks/blob/master/src/xpiks-qt/MetadataIO/metadatareadingworker.cpp#L145



QString exiftoolPath = m_SettingsModel->getExifToolPath();
QStringList arguments;
arguments << "-charset" << "FileName=UTF8";
arguments << "-@" << argumentsFile.fileName();

LOG_DEBUG << "Starting exiftool process:" << exiftoolPath;
m_ExiftoolProcess->start(exiftoolPath, arguments);

success = m_ExiftoolProcess->waitForFinished();

anda_skoa
16th March 2016, 22:36
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,
_