From 7b5c611d80cfbb2fed4e170996072cd4ebcda4b8 Mon Sep 17 00:00:00 2001 From: chrisparker126 Date: Tue, 26 Oct 2010 22:41:47 +0000 Subject: [PATCH] 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 --- .../src/gui/channels/CreateChannelMsg.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/retroshare-gui/src/gui/channels/CreateChannelMsg.cpp b/retroshare-gui/src/gui/channels/CreateChannelMsg.cpp index de98d4226..b097137d3 100644 --- a/retroshare-gui/src/gui/channels/CreateChannelMsg.cpp +++ b/retroshare-gui/src/gui/channels/CreateChannelMsg.cpp @@ -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::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