2007-11-06 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Fixed: Can not resume: aria2 reports download already finished.
	* src/AbstractCommand.{h, cc}
	* src/HttpResponseCommand.cc
	* src/FtpNegotiateCommand.cc
pull/1/head
Tatsuhiro Tsujikawa 2007-11-05 15:50:49 +00:00
parent 52b43151c6
commit 5641ac5b6b
4 changed files with 13 additions and 13 deletions

View File

@ -50,7 +50,7 @@
#include "UnknownLengthPieceStorage.h"
#include "File.h"
#include "StreamCheckIntegrityEntry.h"
#include "DefaultBtProgressInfoFile.h"
#include "BtProgressInfoFile.h"
#include "CheckIntegrityCommand.h"
#include "DiskAdaptor.h"
#include "PeerStat.h"
@ -300,7 +300,7 @@ bool AbstractCommand::nameResolveFinished() const {
}
#endif // ENABLE_ASYNC_DNS
void AbstractCommand::loadAndOpenFile()
void AbstractCommand::loadAndOpenFile(const BtProgressInfoFileHandle& progressInfoFile)
{
if(!_requestGroup->isPreLocalFileCheckEnabled()) {
_requestGroup->getPieceStorage()->getDiskAdaptor()->initAndOpenFile();
@ -308,8 +308,6 @@ void AbstractCommand::loadAndOpenFile()
}
//_requestGroup->setProgressInfoFile(new DefaultBtProgressInfoFile(_requestGroup->getDownloadContext(), _requestGroup->getPieceStorage(), e->option));
BtProgressInfoFileHandle progressInfoFile =
new DefaultBtProgressInfoFile(_requestGroup->getDownloadContext(), _requestGroup->getPieceStorage(), e->option);
if(progressInfoFile->exists()) {
progressInfoFile->load();
_requestGroup->getPieceStorage()->getDiskAdaptor()->openExistingFile();
@ -400,10 +398,6 @@ void AbstractCommand::initPieceStorage()
bool AbstractCommand::downloadFinishedByFileLength()
{
// check existence of control file using ProgressInfoFile class.
if(_requestGroup->getProgressInfoFile()->exists()) {
return false;
}
// TODO consider the case when the getFilePath() returns dir path.
File outfile(_requestGroup->getFilePath());
if(outfile.exists() &&

View File

@ -48,6 +48,8 @@ extern typedef SharedHandle<Segment> SegmentHandle;
extern typedef deque<SegmentHandle> Segments;
class NameResolver;
extern typedef SharedHandle<NameResolver> NameResolverHandle;
class BtProgressInfoFile;
extern typedef SharedHandle<BtProgressInfoFile> BtProgressInfoFileHandle;
class AbstractCommand : public Command, public RequestGroupAware {
private:
@ -76,7 +78,7 @@ protected:
#endif // ENABLE_ASYNC_DNS
void setTimeout(int32_t timeout) { this->timeout = timeout; }
void loadAndOpenFile();
void loadAndOpenFile(const BtProgressInfoFileHandle& progressInfoFile);
bool tryAutoFileRenaming();

View File

@ -44,6 +44,7 @@
#include "prefs.h"
#include "Util.h"
#include "SingleFileDownloadContext.h"
#include "DefaultBtProgressInfoFile.h"
FtpNegotiationCommand::FtpNegotiationCommand(int32_t cuid,
const RequestHandle& req,
@ -207,14 +208,15 @@ bool FtpNegotiationCommand::recvSize() {
return false;
}
BtProgressInfoFileHandle infoFile = new DefaultBtProgressInfoFile(_requestGroup->getDownloadContext(), _requestGroup->getPieceStorage(), e->option);
if(e->option->get(PREF_CHECK_INTEGRITY) != V_TRUE) {
if(downloadFinishedByFileLength()) {
if(!infoFile->exists() && downloadFinishedByFileLength()) {
logger->notice(MSG_DOWNLOAD_ALREADY_COMPLETED, cuid, _requestGroup->getFilePath().c_str());
sequence = SEQ_DOWNLOAD_ALREADY_COMPLETED;
return false;
}
}
loadAndOpenFile();
loadAndOpenFile(infoFile);
prepareForNextAction();
sequence = SEQ_FILE_PREPARATION;

View File

@ -48,6 +48,7 @@
#include "SingleFileDownloadContext.h"
#include "DiskAdaptor.h"
#include "PieceStorage.h"
#include "DefaultBtProgressInfoFile.h"
#include <sys/types.h>
#include <unistd.h>
@ -130,8 +131,9 @@ bool HttpResponseCommand::handleDefaultEncoding(const HttpResponseHandle& httpRe
return true;
}
BtProgressInfoFileHandle infoFile = new DefaultBtProgressInfoFile(_requestGroup->getDownloadContext(), _requestGroup->getPieceStorage(), e->option);
if(e->option->get(PREF_CHECK_INTEGRITY) != V_TRUE) {
if(downloadFinishedByFileLength()) {
if(!infoFile->exists() && downloadFinishedByFileLength()) {
logger->notice(MSG_DOWNLOAD_ALREADY_COMPLETED, cuid, _requestGroup->getFilePath().c_str());
return true;
}
@ -139,11 +141,11 @@ bool HttpResponseCommand::handleDefaultEncoding(const HttpResponseHandle& httpRe
DownloadCommand* command = 0;
try {
loadAndOpenFile(infoFile);
File file(_requestGroup->getFilePath());
if(_requestGroup->getRemainingUris().empty() && !file.exists()) {
command = createHttpDownloadCommand(httpResponse);
}
loadAndOpenFile();
prepareForNextAction(command);
e->noWait = true;
} catch(Exception* e) {