Simplify code in setDateModified

This commit is contained in:
Nicolas Fella 2019-05-16 00:11:38 +02:00
parent 51e4e399f4
commit 5fc354c496

View file

@ -85,13 +85,9 @@ static QString cleanFilename(const QString &filename)
void SharePlugin::setDateModified(const QUrl& destination, const qint64 timestamp) void SharePlugin::setDateModified(const QUrl& destination, const qint64 timestamp)
{ {
QFile receivedFile(destination.toLocalFile()); QFile receivedFile(destination.toLocalFile());
if (!receivedFile.exists()) { if (!receivedFile.exists() || !receivedFile.open(QIODevice::ReadWrite | QIODevice::Text)) {
if (!receivedFile.open(QIODevice::ReadWrite | QIODevice::Text)) { return;
QString error_msg = receivedFile.errorString();
return;
}
} }
receivedFile.open(QIODevice::ReadWrite | QIODevice::Text);
receivedFile.setFileTime(QDateTime::fromMSecsSinceEpoch(timestamp), QFileDevice::FileTime(QFileDevice::FileModificationTime)); receivedFile.setFileTime(QDateTime::fromMSecsSinceEpoch(timestamp), QFileDevice::FileTime(QFileDevice::FileModificationTime));
} }