Do not save avatar files with unknown extensions.

This commit is contained in:
lotodore
2007-10-16 20:48:25 +00:00
parent e5e86a7e43
commit 959b89f9ed
+13 -8
View File
@@ -283,17 +283,22 @@ AvatarManager::StoreAvatarInCache(const MD5Buf &md5buf, AvatarFileType avatarFil
case AVATAR_FILE_TYPE_GIF:
ext = ".gif";
break;
case AVATAR_FILE_TYPE_UNKNOWN:
break;
}
path tmpPath(m_cacheDir);
tmpPath /= (md5buf.ToString() + ext);
string fileName(tmpPath.file_string());
ofstream o(fileName.c_str(), ios_base::out | ios_base::binary);
o.write((const char *)data, size);
if (!ext.empty())
{
boost::mutex::scoped_lock lock(m_cachedAvatarsMutex);
m_cachedAvatars.insert(AvatarMap::value_type(md5buf, fileName));
path tmpPath(m_cacheDir);
tmpPath /= (md5buf.ToString() + ext);
string fileName(tmpPath.file_string());
ofstream o(fileName.c_str(), ios_base::out | ios_base::binary);
o.write((const char *)data, size);
{
boost::mutex::scoped_lock lock(m_cachedAvatarsMutex);
m_cachedAvatars.insert(AvatarMap::value_type(md5buf, fileName));
}
retVal = true;
}
retVal = true;
} catch (...)
{
}