mirror of https://github.com/aria2/aria2
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.ccpull/1/head
parent
52b43151c6
commit
5641ac5b6b
|
@ -50,7 +50,7 @@
|
||||||
#include "UnknownLengthPieceStorage.h"
|
#include "UnknownLengthPieceStorage.h"
|
||||||
#include "File.h"
|
#include "File.h"
|
||||||
#include "StreamCheckIntegrityEntry.h"
|
#include "StreamCheckIntegrityEntry.h"
|
||||||
#include "DefaultBtProgressInfoFile.h"
|
#include "BtProgressInfoFile.h"
|
||||||
#include "CheckIntegrityCommand.h"
|
#include "CheckIntegrityCommand.h"
|
||||||
#include "DiskAdaptor.h"
|
#include "DiskAdaptor.h"
|
||||||
#include "PeerStat.h"
|
#include "PeerStat.h"
|
||||||
|
@ -300,7 +300,7 @@ bool AbstractCommand::nameResolveFinished() const {
|
||||||
}
|
}
|
||||||
#endif // ENABLE_ASYNC_DNS
|
#endif // ENABLE_ASYNC_DNS
|
||||||
|
|
||||||
void AbstractCommand::loadAndOpenFile()
|
void AbstractCommand::loadAndOpenFile(const BtProgressInfoFileHandle& progressInfoFile)
|
||||||
{
|
{
|
||||||
if(!_requestGroup->isPreLocalFileCheckEnabled()) {
|
if(!_requestGroup->isPreLocalFileCheckEnabled()) {
|
||||||
_requestGroup->getPieceStorage()->getDiskAdaptor()->initAndOpenFile();
|
_requestGroup->getPieceStorage()->getDiskAdaptor()->initAndOpenFile();
|
||||||
|
@ -308,8 +308,6 @@ void AbstractCommand::loadAndOpenFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
//_requestGroup->setProgressInfoFile(new DefaultBtProgressInfoFile(_requestGroup->getDownloadContext(), _requestGroup->getPieceStorage(), e->option));
|
//_requestGroup->setProgressInfoFile(new DefaultBtProgressInfoFile(_requestGroup->getDownloadContext(), _requestGroup->getPieceStorage(), e->option));
|
||||||
BtProgressInfoFileHandle progressInfoFile =
|
|
||||||
new DefaultBtProgressInfoFile(_requestGroup->getDownloadContext(), _requestGroup->getPieceStorage(), e->option);
|
|
||||||
if(progressInfoFile->exists()) {
|
if(progressInfoFile->exists()) {
|
||||||
progressInfoFile->load();
|
progressInfoFile->load();
|
||||||
_requestGroup->getPieceStorage()->getDiskAdaptor()->openExistingFile();
|
_requestGroup->getPieceStorage()->getDiskAdaptor()->openExistingFile();
|
||||||
|
@ -400,10 +398,6 @@ void AbstractCommand::initPieceStorage()
|
||||||
|
|
||||||
bool AbstractCommand::downloadFinishedByFileLength()
|
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.
|
// TODO consider the case when the getFilePath() returns dir path.
|
||||||
File outfile(_requestGroup->getFilePath());
|
File outfile(_requestGroup->getFilePath());
|
||||||
if(outfile.exists() &&
|
if(outfile.exists() &&
|
||||||
|
|
|
@ -48,6 +48,8 @@ extern typedef SharedHandle<Segment> SegmentHandle;
|
||||||
extern typedef deque<SegmentHandle> Segments;
|
extern typedef deque<SegmentHandle> Segments;
|
||||||
class NameResolver;
|
class NameResolver;
|
||||||
extern typedef SharedHandle<NameResolver> NameResolverHandle;
|
extern typedef SharedHandle<NameResolver> NameResolverHandle;
|
||||||
|
class BtProgressInfoFile;
|
||||||
|
extern typedef SharedHandle<BtProgressInfoFile> BtProgressInfoFileHandle;
|
||||||
|
|
||||||
class AbstractCommand : public Command, public RequestGroupAware {
|
class AbstractCommand : public Command, public RequestGroupAware {
|
||||||
private:
|
private:
|
||||||
|
@ -76,7 +78,7 @@ protected:
|
||||||
#endif // ENABLE_ASYNC_DNS
|
#endif // ENABLE_ASYNC_DNS
|
||||||
void setTimeout(int32_t timeout) { this->timeout = timeout; }
|
void setTimeout(int32_t timeout) { this->timeout = timeout; }
|
||||||
|
|
||||||
void loadAndOpenFile();
|
void loadAndOpenFile(const BtProgressInfoFileHandle& progressInfoFile);
|
||||||
|
|
||||||
bool tryAutoFileRenaming();
|
bool tryAutoFileRenaming();
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "SingleFileDownloadContext.h"
|
#include "SingleFileDownloadContext.h"
|
||||||
|
#include "DefaultBtProgressInfoFile.h"
|
||||||
|
|
||||||
FtpNegotiationCommand::FtpNegotiationCommand(int32_t cuid,
|
FtpNegotiationCommand::FtpNegotiationCommand(int32_t cuid,
|
||||||
const RequestHandle& req,
|
const RequestHandle& req,
|
||||||
|
@ -207,14 +208,15 @@ bool FtpNegotiationCommand::recvSize() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BtProgressInfoFileHandle infoFile = new DefaultBtProgressInfoFile(_requestGroup->getDownloadContext(), _requestGroup->getPieceStorage(), e->option);
|
||||||
if(e->option->get(PREF_CHECK_INTEGRITY) != V_TRUE) {
|
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());
|
logger->notice(MSG_DOWNLOAD_ALREADY_COMPLETED, cuid, _requestGroup->getFilePath().c_str());
|
||||||
sequence = SEQ_DOWNLOAD_ALREADY_COMPLETED;
|
sequence = SEQ_DOWNLOAD_ALREADY_COMPLETED;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loadAndOpenFile();
|
loadAndOpenFile(infoFile);
|
||||||
prepareForNextAction();
|
prepareForNextAction();
|
||||||
|
|
||||||
sequence = SEQ_FILE_PREPARATION;
|
sequence = SEQ_FILE_PREPARATION;
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include "SingleFileDownloadContext.h"
|
#include "SingleFileDownloadContext.h"
|
||||||
#include "DiskAdaptor.h"
|
#include "DiskAdaptor.h"
|
||||||
#include "PieceStorage.h"
|
#include "PieceStorage.h"
|
||||||
|
#include "DefaultBtProgressInfoFile.h"
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
@ -130,8 +131,9 @@ bool HttpResponseCommand::handleDefaultEncoding(const HttpResponseHandle& httpRe
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BtProgressInfoFileHandle infoFile = new DefaultBtProgressInfoFile(_requestGroup->getDownloadContext(), _requestGroup->getPieceStorage(), e->option);
|
||||||
if(e->option->get(PREF_CHECK_INTEGRITY) != V_TRUE) {
|
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());
|
logger->notice(MSG_DOWNLOAD_ALREADY_COMPLETED, cuid, _requestGroup->getFilePath().c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -139,11 +141,11 @@ bool HttpResponseCommand::handleDefaultEncoding(const HttpResponseHandle& httpRe
|
||||||
|
|
||||||
DownloadCommand* command = 0;
|
DownloadCommand* command = 0;
|
||||||
try {
|
try {
|
||||||
|
loadAndOpenFile(infoFile);
|
||||||
File file(_requestGroup->getFilePath());
|
File file(_requestGroup->getFilePath());
|
||||||
if(_requestGroup->getRemainingUris().empty() && !file.exists()) {
|
if(_requestGroup->getRemainingUris().empty() && !file.exists()) {
|
||||||
command = createHttpDownloadCommand(httpResponse);
|
command = createHttpDownloadCommand(httpResponse);
|
||||||
}
|
}
|
||||||
loadAndOpenFile();
|
|
||||||
prepareForNextAction(command);
|
prepareForNextAction(command);
|
||||||
e->noWait = true;
|
e->noWait = true;
|
||||||
} catch(Exception* e) {
|
} catch(Exception* e) {
|
||||||
|
|
Loading…
Reference in New Issue