mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added a warning and skip files with missing hash in copy link
This commit is contained in:
parent
f314e7d330
commit
e7a119f22c
@ -1010,16 +1010,6 @@ void RetroshareDirModel::postMods()
|
|||||||
beginResetModel();
|
beginResetModel();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// QModelIndexList piList = persistentIndexList();
|
|
||||||
// QModelIndexList empty;
|
|
||||||
// for (int i = 0; i < piList.size(); ++i) {
|
|
||||||
// empty.append(QModelIndex());
|
|
||||||
// }
|
|
||||||
// changePersistentIndexList(piList, empty);
|
|
||||||
|
|
||||||
/* Clear caches */
|
|
||||||
//mCache.clear();
|
|
||||||
|
|
||||||
#ifdef RDM_DEBUG
|
#ifdef RDM_DEBUG
|
||||||
std::cerr << "RetroshareDirModel::postMods()" << std::endl;
|
std::cerr << "RetroshareDirModel::postMods()" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -1059,30 +1049,6 @@ bool RetroshareDirModel::requestDirDetails(void *ref, bool remote,DirDetails& d)
|
|||||||
|
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
// const QMap<void*, DirDetailsVector>::const_iterator it = mCache.constFind(ref);
|
|
||||||
// if (it != mCache.constEnd()) {
|
|
||||||
// /* Details found in cache */
|
|
||||||
// return &it.value();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//#warning this is terrible! A vector in a std::map will keep being copied and create a lot of CPU overload. Use a pointer instead.
|
|
||||||
// /* Get details from the lib */
|
|
||||||
//
|
|
||||||
// if (rsFiles->RequestDirDetails(ref, details, flags)) {
|
|
||||||
// /* Convert std::list to std::vector for fast access with index */
|
|
||||||
// std::list<DirStub>::const_iterator childIt;
|
|
||||||
// for (childIt = details.children.begin(); childIt != details.children.end(); ++childIt) {
|
|
||||||
// details.childrenVector.push_back(*childIt);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /* Add to cache, must cast to none const */
|
|
||||||
// const QMap<void*, DirDetailsVector>::iterator it1 = ((QMap<void*, DirDetailsVector>*) &mCache)->insert(ref, details);
|
|
||||||
// return &it1.value();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /* No details found */
|
|
||||||
// return NULL;
|
|
||||||
//}
|
|
||||||
|
|
||||||
void RetroshareDirModel::createCollectionFile(QWidget *parent, const QModelIndexList &list)
|
void RetroshareDirModel::createCollectionFile(QWidget *parent, const QModelIndexList &list)
|
||||||
{
|
{
|
||||||
|
@ -146,7 +146,6 @@ class RetroshareDirModel : public QAbstractItemModel
|
|||||||
};
|
};
|
||||||
|
|
||||||
bool RemoteMode;
|
bool RemoteMode;
|
||||||
QMap<void*, DirDetailsVector> mCache;
|
|
||||||
|
|
||||||
mutable int nIndex;
|
mutable int nIndex;
|
||||||
mutable std::vector<RemoteIndex> indexSet;
|
mutable std::vector<RemoteIndex> indexSet;
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
#include <QMessageBox>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QStyledItemDelegate>
|
#include <QStyledItemDelegate>
|
||||||
|
|
||||||
@ -583,6 +584,8 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
|
|||||||
|
|
||||||
QList<RetroShareLink> urls ;
|
QList<RetroShareLink> urls ;
|
||||||
|
|
||||||
|
bool has_unhashed_files = false;
|
||||||
|
|
||||||
for (int i = 0, n = dirVec.size(); i < n; ++i)
|
for (int i = 0, n = dirVec.size(); i < n; ++i)
|
||||||
{
|
{
|
||||||
const DirDetails& details = dirVec[i];
|
const DirDetails& details = dirVec[i];
|
||||||
@ -600,6 +603,12 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
|
|||||||
if (!rsFiles->RequestDirDetails(dirStub.ref, details, flags) || details.type != DIR_TYPE_FILE)
|
if (!rsFiles->RequestDirDetails(dirStub.ref, details, flags) || details.type != DIR_TYPE_FILE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if(details.hash.isNull())
|
||||||
|
{
|
||||||
|
has_unhashed_files = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
RetroShareLink link;
|
RetroShareLink link;
|
||||||
if (link.createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.toStdString().c_str())) {
|
if (link.createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.toStdString().c_str())) {
|
||||||
urls.push_back(link) ;
|
urls.push_back(link) ;
|
||||||
@ -608,6 +617,11 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if(details.hash.isNull())
|
||||||
|
{
|
||||||
|
has_unhashed_files = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
RetroShareLink link;
|
RetroShareLink link;
|
||||||
if (link.createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.toStdString().c_str())) {
|
if (link.createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.toStdString().c_str())) {
|
||||||
urls.push_back(link) ;
|
urls.push_back(link) ;
|
||||||
@ -615,6 +629,9 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
RSLinkClipboard::copyLinks(urls) ;
|
RSLinkClipboard::copyLinks(urls) ;
|
||||||
|
|
||||||
|
if(has_unhashed_files)
|
||||||
|
QMessageBox::warning(NULL,tr("Some files have been omitted"),tr("Some files have been ommitted because their hash is not available yet.")) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SharedFilesDialog::copyLink()
|
void SharedFilesDialog::copyLink()
|
||||||
|
@ -277,7 +277,7 @@ void ChatLobbyDialog::voteParticipant()
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
RsReputations::Opinion op(act->data().toUInt()) ;
|
RsReputations::Opinion op = RsReputations::Opinion(act->data().toUInt()) ;
|
||||||
|
|
||||||
for (item = selectedItems.begin(); item != selectedItems.end(); ++item)
|
for (item = selectedItems.begin(); item != selectedItems.end(); ++item)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user