1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Instead of saving empty files, delete empty avatars

This commit is contained in:
tux3 2015-12-19 16:43:09 +01:00
parent cbe8104576
commit 40ddf81fd1
No known key found for this signature in database
GPG Key ID: 7E086DD661263264

View File

@ -396,14 +396,21 @@ void Profile::saveAvatar(QByteArray pic, const QString &ownerId)
QString path = avatarPath(ownerId);
QDir(Settings::getInstance().getSettingsDirPath()).mkdir("avatars");
QSaveFile file(path);
if (!file.open(QIODevice::WriteOnly))
if (pic.isEmpty())
{
qWarning() << "Tox avatar " << path << " couldn't be saved";
return;
QFile::remove(path);
}
else
{
QSaveFile file(path);
if (!file.open(QIODevice::WriteOnly))
{
qWarning() << "Tox avatar " << path << " couldn't be saved";
return;
}
file.write(pic);
file.commit();
}
file.write(pic);
file.commit();
}
QByteArray Profile::getAvatarHash(const QString &ownerId)