Browse Source

Instead of saving empty files, delete empty avatars

pull/2701/head
tux3 10 years ago
parent
commit
40ddf81fd1
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
  1. 19
      src/persistence/profile.cpp

19
src/persistence/profile.cpp

@ -396,14 +396,21 @@ void Profile::saveAvatar(QByteArray pic, const QString &ownerId) @@ -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)

Loading…
Cancel
Save