mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-11 23:49:38 -05:00
* Improvements to Upload information output: destination id, size and rate of last transfer
* Deletes fileCache after 30 seconds of inactivity. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@574 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
42579f4dec
commit
dd771b9940
@ -61,6 +61,8 @@ const float TRANSFER_MODE_FAST_RATE = 500000; /* 500 kbyte limit */
|
||||
const uint32_t TRANSFER_START_MIN = 500; /* 500 byte min limit */
|
||||
const uint32_t TRANSFER_START_MAX = 10000; /* 10000 byte max limit */
|
||||
|
||||
const uint32_t CACHE_FILE_TIMEOUT = 30; /* 30 seconds */
|
||||
|
||||
void printFtFileStatus(ftFileStatus *s, std::ostream &out);
|
||||
|
||||
/************* Local File Interface ****************************
|
||||
@ -414,13 +416,7 @@ std::list<RsFileTransfer *> ftfiler::getStatus()
|
||||
RsFileTransfer *rft = new RsFileTransfer();
|
||||
rft -> in = false;
|
||||
|
||||
/* Ids: current and all */
|
||||
std::list<std::string>::iterator pit;
|
||||
for(pit = (*it)->sources.begin();
|
||||
pit != (*it)->sources.end(); pit++)
|
||||
{
|
||||
rft->allPeerIds.ids.push_back(*pit);
|
||||
}
|
||||
/* Only set the most recent */
|
||||
rft -> cPeerId = (*it)->id;
|
||||
|
||||
/* file details */
|
||||
@ -437,10 +433,10 @@ std::list<RsFileTransfer *> ftfiler::getStatus()
|
||||
rft -> file.hash = "";
|
||||
|
||||
/* Fill in rate and State */
|
||||
rft -> transferred = (*it)->recv_size;
|
||||
rft -> crate = (*it)->rate; // bytes.
|
||||
rft -> trate = (*it)->rate; // bytes.
|
||||
rft -> lrate = (*it)->rate; // bytes.
|
||||
rft -> transferred = (*it)->req_loc;
|
||||
rft -> crate = (*it)->req_size / 10.0; /* very approx */
|
||||
rft -> trate = (*it)->req_size / 10.0;
|
||||
rft -> lrate = (*it)->req_size / 10.0;
|
||||
rft -> ltransfer = (*it)->req_size;
|
||||
|
||||
/* get inactive period */
|
||||
@ -463,7 +459,9 @@ std::list<RsFileTransfer *> ftfiler::getStatus()
|
||||
}
|
||||
else if ((*it) -> status == PQIFILE_COMPLETE)
|
||||
{
|
||||
rft -> state = FT_STATE_COMPLETE;
|
||||
// uploads are going while they are here..
|
||||
//rft -> state = FT_STATE_COMPLETE;
|
||||
rft -> state = FT_STATE_DOWNLOADING;
|
||||
}
|
||||
else if ((*it) -> status == PQIFILE_DOWNLOADING)
|
||||
{
|
||||
@ -762,6 +760,24 @@ void ftfiler::queryInactive()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* check the cached upload files too */
|
||||
time_t now = time(NULL);
|
||||
for(it = fileCache.begin(); it != fileCache.end();) /* increment at end of loop */
|
||||
{
|
||||
if (now - (*it)->lastTS > CACHE_FILE_TIMEOUT)
|
||||
{
|
||||
std::cerr << "Clearing Timed-out Cache File: " << (*it)->name;
|
||||
std::cerr << std::endl;
|
||||
delete (*it);
|
||||
it = fileCache.erase(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
||||
pqioutput(PQL_DEBUG_BASIC, ftfilerzone, out.str());
|
||||
}
|
||||
|
||||
@ -1001,6 +1017,20 @@ int ftfiler::generateFileData(ftFileStatus *s, std::string id, uint64_t offset,
|
||||
|
||||
/* send off the packet */
|
||||
out_queue.push_back(fd);
|
||||
|
||||
/* Update status of ftFileStatus to reflect last usage (for GUI display)
|
||||
* We need to store.
|
||||
* (a) Id,
|
||||
* (b) Offset,
|
||||
* (c) Size,
|
||||
* (d) timestamp
|
||||
*/
|
||||
|
||||
time_t now = time(NULL);
|
||||
s->id = id;
|
||||
s->req_loc = offset;
|
||||
s->req_size = tosend;
|
||||
s->lastTS = now;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -1483,6 +1513,8 @@ ftFileStatus *ftfiler::createFileCache(std::string hash)
|
||||
s->req_loc = 0; /* no request */
|
||||
s->req_size = 0;
|
||||
|
||||
s->name = RsDirUtil::getTopDir(s->file_name);
|
||||
|
||||
/* we are now ready for transfers */
|
||||
s->fd = fd;
|
||||
s->lastTS = 0;
|
||||
|
@ -115,7 +115,7 @@ public:
|
||||
|
||||
|
||||
/* data */
|
||||
std::string id; /* current source */
|
||||
std::string id; /* current source / most recent destination */
|
||||
std::string name;
|
||||
std::string hash;
|
||||
std::string destpath;
|
||||
@ -138,12 +138,12 @@ public:
|
||||
* otherwise - need much more status info */
|
||||
uint64_t recv_size;
|
||||
|
||||
/* current file data request */
|
||||
/* current file data request / most recent request answered (upload) */
|
||||
uint64_t req_loc;
|
||||
uint32_t req_size;
|
||||
|
||||
/* timestamp */
|
||||
time_t lastTS;
|
||||
time_t lastTS; /* last request / request answered (upload) */
|
||||
uint32_t lastDelta; /* send til all recved */
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user