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:
parent
cbe8104576
commit
40ddf81fd1
|
@ -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…
Reference in New Issue
Block a user