mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
restore file state when restart (Modified patch from Phenom)
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6807 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
e9ccc323a2
commit
67517ad074
@ -1017,7 +1017,7 @@ bool ftController::handleAPendingRequest()
|
||||
std::cerr << "Requesting pending hash " << req.mHash << std::endl ;
|
||||
#endif
|
||||
|
||||
FileRequest(req.mName, req.mHash, req.mSize, req.mDest, TransferRequestFlags(req.mFlags), req.mSrcIds);
|
||||
FileRequest(req.mName, req.mHash, req.mSize, req.mDest, TransferRequestFlags(req.mFlags), req.mSrcIds, req.mState);
|
||||
|
||||
{
|
||||
// See whether there is a pendign chunk map recorded for this hash.
|
||||
@ -1045,6 +1045,7 @@ bool ftController::handleAPendingRequest()
|
||||
#endif
|
||||
(fit->second)->mCreator->setAvailabilityMap(rsft->compressed_chunk_map) ;
|
||||
(fit->second)->mCreator->setChunkStrategy((FileChunksInfo::ChunkStrategy)(rsft->chunk_strategy)) ;
|
||||
(fit->second)->mState=rsft->state;
|
||||
}
|
||||
|
||||
delete rsft ;
|
||||
@ -1074,7 +1075,7 @@ bool ftController::alreadyHaveFile(const std::string& hash, FileInfo &info)
|
||||
|
||||
bool ftController::FileRequest(const std::string& fname, const std::string& hash,
|
||||
uint64_t size, const std::string& dest, TransferRequestFlags flags,
|
||||
const std::list<std::string> &_srcIds)
|
||||
const std::list<std::string> &_srcIds, uint16_t state)
|
||||
{
|
||||
std::list<std::string> srcIds(_srcIds) ;
|
||||
|
||||
@ -1129,7 +1130,7 @@ bool ftController::FileRequest(const std::string& fname, const std::string& has
|
||||
if (!mFtActive)
|
||||
{
|
||||
/* store in pending queue */
|
||||
ftPendingRequest req(fname, hash, size, dest, flags, srcIds);
|
||||
ftPendingRequest req(fname, hash, size, dest, flags, srcIds,state);
|
||||
mPendingRequests.push_back(req);
|
||||
return true;
|
||||
}
|
||||
@ -1488,6 +1489,8 @@ bool ftController::FileControl(const std::string& hash, uint32_t flags)
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
IndicateConfigChanged() ;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2109,6 +2112,7 @@ bool ftController::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
||||
rft->file.filesize = pit->mSize;
|
||||
RsDirUtil::removeTopDir(pit->mDest, rft->file.path); /* remove fname */
|
||||
rft->flags = pit->mFlags.toUInt32();
|
||||
rft->state = pit->mState;
|
||||
rft->allPeerIds.ids = pit->mSrcIds;
|
||||
}
|
||||
|
||||
@ -2178,7 +2182,7 @@ bool ftController::loadList(std::list<RsItem *>& load)
|
||||
#ifdef CONTROL_DEBUG
|
||||
std::cerr << "ftController::loadList(): requesting " << rsft->file.name << ", " << rsft->file.hash << ", " << rsft->file.filesize << std::endl ;
|
||||
#endif
|
||||
FileRequest(rsft->file.name, rsft->file.hash, rsft->file.filesize, rsft->file.path, TransferRequestFlags(rsft->flags), rsft->allPeerIds.ids);
|
||||
FileRequest(rsft->file.name, rsft->file.hash, rsft->file.filesize, rsft->file.path, TransferRequestFlags(rsft->flags), rsft->allPeerIds.ids, rsft->state);
|
||||
|
||||
{
|
||||
RsStackMutex mtx(ctrlMutex) ;
|
||||
|
@ -96,11 +96,11 @@ class ftPendingRequest
|
||||
public:
|
||||
ftPendingRequest(const std::string& fname, const std::string& hash,
|
||||
uint64_t size, const std::string& dest, TransferRequestFlags flags,
|
||||
const std::list<std::string> &srcIds)
|
||||
const std::list<std::string> &srcIds, uint16_t state)
|
||||
: mName(fname), mHash(hash), mSize(size),
|
||||
mDest(dest), mFlags(flags),mSrcIds(srcIds) { return; }
|
||||
mDest(dest), mFlags(flags), mSrcIds(srcIds), mState(state) { return; }
|
||||
|
||||
ftPendingRequest() : mSize(0), mFlags(0) { return; }
|
||||
ftPendingRequest() : mSize(0), mFlags(0), mState(0) { return; }
|
||||
|
||||
std::string mName;
|
||||
std::string mHash;
|
||||
@ -108,6 +108,7 @@ class ftPendingRequest
|
||||
std::string mDest;
|
||||
TransferRequestFlags mFlags;
|
||||
std::list<std::string> mSrcIds;
|
||||
uint16_t mState;
|
||||
};
|
||||
|
||||
|
||||
@ -132,7 +133,7 @@ class ftController: public CacheTransfer, public RsThread, public pqiMonitor, pu
|
||||
|
||||
bool FileRequest(const std::string& fname, const std::string& hash,
|
||||
uint64_t size, const std::string& dest, TransferRequestFlags flags,
|
||||
const std::list<std::string> &sourceIds);
|
||||
const std::list<std::string> &sourceIds, uint16_t state = ftFileControl::DOWNLOADING);
|
||||
|
||||
/// Do we already have this file, either in download or in file lists ?
|
||||
bool alreadyHaveFile(const std::string& hash, FileInfo &info);
|
||||
@ -192,7 +193,7 @@ class ftController: public CacheTransfer, public RsThread, public pqiMonitor, pu
|
||||
|
||||
protected:
|
||||
|
||||
virtual bool RequestCacheFile(RsPeerId id, std::string path, std::string hash, uint64_t size);
|
||||
virtual bool RequestCacheFile(RsPeerId id, std::string path, std::string hash, uint64_t size);
|
||||
virtual bool CancelCacheFile(RsPeerId id, std::string path, std::string hash, uint64_t size);
|
||||
|
||||
void cleanCacheDownloads() ;
|
||||
|
Loading…
Reference in New Issue
Block a user