don't allow user to add same file twice to createchanmsg instance

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3700 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2010-10-26 22:41:47 +00:00
parent fb6de2aaf4
commit 7b5c611d80

View File

@ -301,11 +301,30 @@ void CreateChannelMsg::addAttachment(const std::string &path)
/* add widget in for new destination */
uint32_t flags = SFI_TYPE_CHANNEL | SFI_STATE_EXTRA;
// check attachment if hash exists already
std::list<SubFileItem* >::iterator it;
for(it= mAttachments.begin(); it != mAttachments.end(); it++){
if((*it)->FilePath() == path){
QMessageBox::warning(this, tr("RetroShare"),
tr("File already Added and Hashed"),
QMessageBox::Ok, QMessageBox::Ok);
return;
}
}
// channels creates copy of file into channels directory and shares this
FileInfo fInfo;
rsChannels->channelExtraFileHash(path, mChannelId, fInfo);
// file is not innitial
SubFileItem *file = new SubFileItem(fInfo.hash, fInfo.fname, fInfo.path, fInfo.size,
flags, mChannelId); // destroyed when fileFrame (this subfileitem) is destroyed