mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 14:16:16 -04:00
added possibility to remove extra shared file
This commit is contained in:
parent
1383846364
commit
7ab7c7db93
13 changed files with 125 additions and 69 deletions
|
@ -37,8 +37,8 @@
|
|||
#define P3FILELISTS_ERROR() std::cerr << "***ERROR***" << " : FILE_LISTS : " << __FUNCTION__ << " : "
|
||||
|
||||
//#define DEBUG_P3FILELISTS 1
|
||||
#define DEBUG_CONTENT_FILTERING 1
|
||||
#define DEBUG_FILE_HIERARCHY 1
|
||||
//#define DEBUG_CONTENT_FILTERING 1
|
||||
//#define DEBUG_FILE_HIERARCHY 1
|
||||
|
||||
static const uint32_t P3FILELISTS_UPDATE_FLAG_NOTHING_CHANGED = 0x0000 ;
|
||||
static const uint32_t P3FILELISTS_UPDATE_FLAG_REMOTE_MAP_CHANGED = 0x0001 ;
|
||||
|
@ -960,6 +960,14 @@ int p3FileDatabase::getSharedDirStatistics(const RsPeerId& pid,SharedDirStats& s
|
|||
}
|
||||
}
|
||||
|
||||
void p3FileDatabase::removeExtraFile(const RsFileHash& hash)
|
||||
{
|
||||
RS_STACK_MUTEX(mFLSMtx) ;
|
||||
|
||||
mExtraFiles->removeExtraFile(hash);
|
||||
mLastExtraFilesCacheUpdate = 0 ; // forced cache reload
|
||||
}
|
||||
|
||||
void p3FileDatabase::getExtraFilesDirDetails(void *ref,DirectoryStorage::EntryIndex e,DirDetails& d) const
|
||||
{
|
||||
// update the cache of extra files if last requested too long ago
|
||||
|
@ -1001,7 +1009,7 @@ void p3FileDatabase::getExtraFilesDirDetails(void *ref,DirectoryStorage::EntryIn
|
|||
else // extra file. Just query the corresponding data from ftExtra
|
||||
{
|
||||
d.prow = 1;//fi-1 ;
|
||||
d.type = DIR_TYPE_FILE;
|
||||
d.type = DIR_TYPE_EXTRA_FILE;
|
||||
|
||||
FileInfo& f(mExtraFilesCache[(int)e-1]) ;
|
||||
|
||||
|
@ -1068,7 +1076,7 @@ int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags
|
|||
{
|
||||
convertEntryIndexToPointer<sizeof(void*)>(0,1,p); // local shared files from extra list
|
||||
DirStub stub;
|
||||
stub.type = DIR_TYPE_PERSON;
|
||||
stub.type = DIR_TYPE_PERSON; // not totally exact, but used as a trick.
|
||||
stub.name = "Temporary shared files";
|
||||
stub.ref = p;
|
||||
|
||||
|
@ -1179,7 +1187,7 @@ int p3FileDatabase::RequestDirDetails(const RsPeerId &/*uid*/, const std::string
|
|||
// NOT_IMPLEMENTED();
|
||||
// return 0;
|
||||
//}
|
||||
uint32_t p3FileDatabase::getType(void *ref) const
|
||||
uint32_t p3FileDatabase::getType(void *ref,FileSearchFlags flags) const
|
||||
{
|
||||
RS_STACK_MUTEX(mFLSMtx) ;
|
||||
|
||||
|
@ -1194,12 +1202,25 @@ uint32_t p3FileDatabase::getType(void *ref) const
|
|||
if(e == 0)
|
||||
return DIR_TYPE_PERSON ;
|
||||
|
||||
if(fi == 0 && mLocalSharedDirs != NULL)
|
||||
return mLocalSharedDirs->getEntryType(e) ;
|
||||
else if(fi-1 < mRemoteDirectories.size() && mRemoteDirectories[fi-1]!=NULL)
|
||||
return mRemoteDirectories[fi-1]->getEntryType(e) ;
|
||||
else
|
||||
if(flags & RS_FILE_HINTS_LOCAL)
|
||||
{
|
||||
if(fi == 0 && mLocalSharedDirs != NULL)
|
||||
return mLocalSharedDirs->getEntryType(e) ;
|
||||
|
||||
if(fi == 1)
|
||||
return DIR_TYPE_EXTRA_FILE;
|
||||
|
||||
P3FILELISTS_ERROR() << " Cannot determine type of entry " << ref << std::endl;
|
||||
return DIR_TYPE_ROOT ;// some failure case. Should not happen
|
||||
}
|
||||
else
|
||||
{
|
||||
if(fi-1 < mRemoteDirectories.size() && mRemoteDirectories[fi-1]!=NULL)
|
||||
return mRemoteDirectories[fi-1]->getEntryType(e) ;
|
||||
|
||||
P3FILELISTS_ERROR() << " Cannot determine type of entry " << ref << std::endl;
|
||||
return DIR_TYPE_ROOT ;// some failure case. Should not happen
|
||||
}
|
||||
}
|
||||
|
||||
void p3FileDatabase::forceDirectoryCheck() // Force re-sweep the directories and see what's changed
|
||||
|
|
|
@ -109,6 +109,9 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
|
|||
virtual int SearchKeywords(const std::list<std::string>& keywords, std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& peer_id) ;
|
||||
virtual int SearchBoolExp(RsRegularExpression::Expression *exp, std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& peer_id) const ;
|
||||
|
||||
// Extra file list
|
||||
virtual void removeExtraFile(const RsFileHash& hash);
|
||||
|
||||
// Interface for browsing dir hierarchy
|
||||
//
|
||||
|
||||
|
@ -121,7 +124,7 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
|
|||
|
||||
void requestDirUpdate(void *ref) ; // triggers an update. Used when browsing.
|
||||
int RequestDirDetails(void *, DirDetails&, FileSearchFlags) const ;
|
||||
uint32_t getType(void *) const ;
|
||||
uint32_t getType(void *, FileSearchFlags flags) const ;
|
||||
|
||||
// proxy method used by the web UI. Dont't delete!
|
||||
int RequestDirDetails(const RsPeerId& uid, const std::string& path, DirDetails &details)const;
|
||||
|
|
|
@ -166,11 +166,9 @@ bool ftExtraList::addExtraFile(std::string path, const RsFileHash& hash,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ftExtraList::removeExtraFile(const RsFileHash& hash, TransferRequestFlags flags)
|
||||
bool ftExtraList::removeExtraFile(const RsFileHash& hash)
|
||||
{
|
||||
/* remove unused parameter warnings */
|
||||
(void) flags;
|
||||
|
||||
#ifdef DEBUG_ELIST
|
||||
std::cerr << "ftExtraList::removeExtraFile()";
|
||||
std::cerr << " hash: " << hash;
|
||||
|
|
|
@ -117,7 +117,7 @@ public:
|
|||
bool addExtraFile(std::string path, const RsFileHash &hash,
|
||||
uint64_t size, uint32_t period, TransferRequestFlags flags);
|
||||
|
||||
bool removeExtraFile(const RsFileHash& hash, TransferRequestFlags flags);
|
||||
bool removeExtraFile(const RsFileHash& hash);
|
||||
bool moveExtraFile(std::string fname, const RsFileHash& hash, uint64_t size,
|
||||
std::string destpath);
|
||||
|
||||
|
|
|
@ -677,9 +677,10 @@ bool ftServer::ExtraFileAdd(std::string fname, const RsFileHash& hash, uint64_t
|
|||
return mFtExtra->addExtraFile(fname, hash, size, period, flags);
|
||||
}
|
||||
|
||||
bool ftServer::ExtraFileRemove(const RsFileHash& hash, TransferRequestFlags flags)
|
||||
bool ftServer::ExtraFileRemove(const RsFileHash& hash)
|
||||
{
|
||||
return mFtExtra->removeExtraFile(hash, flags);
|
||||
mFileDatabase->removeExtraFile(hash);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ftServer::ExtraFileHash(std::string localpath, uint32_t period, TransferRequestFlags flags)
|
||||
|
@ -714,9 +715,9 @@ int ftServer::RequestDirDetails(void *ref, DirDetails &details, FileSearchFlags
|
|||
{
|
||||
return mFileDatabase->RequestDirDetails(ref,details,flags) ;
|
||||
}
|
||||
uint32_t ftServer::getType(void *ref, FileSearchFlags /* flags */)
|
||||
uint32_t ftServer::getType(void *ref, FileSearchFlags flags)
|
||||
{
|
||||
return mFileDatabase->getType(ref) ;
|
||||
return mFileDatabase->getType(ref,flags) ;
|
||||
}
|
||||
/***************************************************************/
|
||||
/******************** Search Interface *************************/
|
||||
|
|
|
@ -180,7 +180,7 @@ public:
|
|||
* Extra List Access
|
||||
***/
|
||||
virtual bool ExtraFileAdd(std::string fname, const RsFileHash& hash, uint64_t size, uint32_t period, TransferRequestFlags flags);
|
||||
virtual bool ExtraFileRemove(const RsFileHash& hash, TransferRequestFlags flags);
|
||||
virtual bool ExtraFileRemove(const RsFileHash& hash);
|
||||
virtual bool ExtraFileHash(std::string localpath, uint32_t period, TransferRequestFlags flags);
|
||||
virtual bool ExtraFileStatus(std::string localpath, FileInfo &info);
|
||||
virtual bool ExtraFileMove(std::string fname, const RsFileHash& hash, uint64_t size, std::string destpath);
|
||||
|
|
|
@ -409,7 +409,7 @@ public:
|
|||
* Extra List Access
|
||||
***/
|
||||
//virtual bool ExtraFileAdd(std::string fname, std::string hash, uint64_t size, uint32_t period, TransferRequestFlags flags) = 0;
|
||||
virtual bool ExtraFileRemove(const RsFileHash& hash, TransferRequestFlags flags) = 0;
|
||||
virtual bool ExtraFileRemove(const RsFileHash& hash) = 0;
|
||||
virtual bool ExtraFileHash(std::string localpath, uint32_t period, TransferRequestFlags flags) = 0;
|
||||
virtual bool ExtraFileStatus(std::string localpath, FileInfo &info) = 0;
|
||||
virtual bool ExtraFileMove(std::string fname, const RsFileHash& hash, uint64_t size, std::string destpath) = 0;
|
||||
|
|
|
@ -160,7 +160,7 @@ struct PeerBandwidthLimits : RsSerializable
|
|||
#define DIR_TYPE_PERSON 0x02
|
||||
#define DIR_TYPE_DIR 0x04
|
||||
#define DIR_TYPE_FILE 0x08
|
||||
#define DIR_TYPE_EXTRA 0x10
|
||||
#define DIR_TYPE_EXTRA_FILE 0x10
|
||||
|
||||
/* flags for Directry request -
|
||||
* two types;
|
||||
|
|
|
@ -1291,9 +1291,9 @@ bool p3GxsChannels::ExtraFileHash(const std::string& path)
|
|||
|
||||
bool p3GxsChannels::ExtraFileRemove(const RsFileHash &hash)
|
||||
{
|
||||
TransferRequestFlags tflags = RS_FILE_REQ_ANONYMOUS_ROUTING | RS_FILE_REQ_EXTRA;
|
||||
//TransferRequestFlags tflags = RS_FILE_REQ_ANONYMOUS_ROUTING | RS_FILE_REQ_EXTRA;
|
||||
RsFileHash fh = RsFileHash(hash);
|
||||
return rsFiles->ExtraFileRemove(fh, tflags);
|
||||
return rsFiles->ExtraFileRemove(fh);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue