2009-03-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Removed getName() from DownloadContext. getName() is declared in
	BtContext.
	* src/BtContext.h
	* src/DownloadContext.h
	* src/SingleFileDownloadContext.cc
	* src/SingleFileDownloadContext.h
		
	Removed getFilePath() from DiskAdaptor. getFilePath() is
	declared in AbstractSingleDiskAdaptor.
	* src/AbstractSingleDiskAdaptor.h
	* src/DiskAdaptor.h
	* src/MultiDiskAdaptor.h
	* src/RequestGroup.cc
	
	Removed setTopDir() and getTopDir() and getTopDirPath() from
	MultiDiskAdaptor.
	* src/DefaultPieceStorage.cc
	* src/MultiDiskAdaptor.cc
	* src/MultiDiskAdaptor.h
	* test/MultiDiskAdaptorTest.cc
This commit is contained in:
Tatsuhiro Tsujikawa 2009-03-10 12:24:29 +00:00
parent e2704bd823
commit 849a533d61
12 changed files with 31 additions and 42 deletions

View file

@ -1,3 +1,26 @@
2009-03-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Removed getName() from DownloadContext. getName() is declared in
BtContext.
* src/BtContext.h
* src/DownloadContext.h
* src/SingleFileDownloadContext.cc
* src/SingleFileDownloadContext.h
Removed getFilePath() from DiskAdaptor. getFilePath() is declared
in AbstractSingleDiskAdaptor.
* src/AbstractSingleDiskAdaptor.h
* src/DiskAdaptor.h
* src/MultiDiskAdaptor.h
* src/RequestGroup.cc
Removed setTopDir() and getTopDir() and getTopDirPath() from
MultiDiskAdaptor.
* src/DefaultPieceStorage.cc
* src/MultiDiskAdaptor.cc
* src/MultiDiskAdaptor.h
* test/MultiDiskAdaptorTest.cc
2009-03-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
FileEntry::getPath() contains store(top level) directory to

View file

@ -86,6 +86,8 @@ public:
virtual void cutTrailingGarbage();
virtual std::string getFilePath() = 0;
void setDiskWriter(const SharedHandle<DiskWriter>& diskWriter);
SharedHandle<DiskWriter> getDiskWriter() const;

View file

@ -85,6 +85,8 @@ public:
virtual std::deque<std::pair<std::string, uint16_t> >& getNodes() = 0;
virtual const std::string& getName() const = 0;
void setFileFilter(const IntSequence& seq);
IntSequence getFileFilter() const;

View file

@ -495,7 +495,6 @@ void DefaultPieceStorage::initStorage()
MultiDiskAdaptorHandle multiDiskAdaptor(new MultiDiskAdaptor());
multiDiskAdaptor->setDirectIOAllowed(option->getAsBool(PREF_ENABLE_DIRECT_IO));
multiDiskAdaptor->setPieceLength(downloadContext->getPieceLength());
multiDiskAdaptor->setTopDir(downloadContext->getName());
multiDiskAdaptor->setMaxOpenFiles(option->getAsInt(PREF_BT_MAX_OPEN_FILES));
this->diskAdaptor = multiDiskAdaptor;
} else {
@ -504,9 +503,8 @@ void DefaultPieceStorage::initStorage()
writer->setDirectIOAllowed(option->getAsBool(PREF_ENABLE_DIRECT_IO));
CopyDiskAdaptorHandle copyDiskAdaptor(new CopyDiskAdaptor());
copyDiskAdaptor->setDiskWriter(writer);
copyDiskAdaptor->setTempFilename(downloadContext->getName()+".a2tmp");
//copyDiskAdaptor->setTempFilename(downloadContext->getName()+".a2tmp");
copyDiskAdaptor->setTotalLength(downloadContext->getTotalLength());
copyDiskAdaptor->setTopDir(downloadContext->getName());
this->diskAdaptor = copyDiskAdaptor;
}
}

View file

@ -67,8 +67,6 @@ public:
virtual bool fileExists() = 0;
virtual std::string getFilePath() = 0;
virtual uint64_t size() = 0;
// optional behavior

View file

@ -81,8 +81,6 @@ public:
virtual std::deque<SharedHandle<FileEntry> > getFileEntries() const = 0;
virtual const std::string& getName() const = 0;
virtual size_t getPieceLength() const = 0;
virtual size_t getNumPieces() const = 0;

View file

@ -282,11 +282,6 @@ void MultiDiskAdaptor::resetDiskWriterEntries()
}
}
std::string MultiDiskAdaptor::getTopDirPath() const
{
return storeDir+"/"+topDir;
}
void MultiDiskAdaptor::mkdir() const
{
for(std::deque<SharedHandle<DiskWriterEntry> >::const_iterator i =
@ -473,9 +468,6 @@ ssize_t MultiDiskAdaptor::readData(unsigned char* data, size_t len, off_t offset
bool MultiDiskAdaptor::fileExists()
{
// TODO Use FileEntry::fileExists() here.
// Don't use _cachedTopDirPath because they are initialized after opening files.
// This method could be called before opening files.
for(std::deque<SharedHandle<FileEntry> >::iterator i =
fileEntries.begin(); i != fileEntries.end(); ++i) {
if(File((*i)->getPath()).exists()) {

View file

@ -101,7 +101,6 @@ typedef std::deque<DiskWriterEntryHandle> DiskWriterEntries;
class MultiDiskAdaptor : public DiskAdaptor {
friend class MultiFileAllocationIterator;
private:
std::string topDir;
size_t pieceLength;
DiskWriterEntries diskWriterEntries;
@ -117,8 +116,6 @@ private:
void mkdir() const;
std::string getTopDirPath() const;
void openIfNot(const SharedHandle<DiskWriterEntry>& entry,
void (DiskWriterEntry::*f)());
@ -146,11 +143,6 @@ public:
virtual bool fileExists();
virtual std::string getFilePath()
{
return getTopDirPath();
}
virtual uint64_t size();
virtual SharedHandle<FileAllocationIterator> fileAllocationIterator();
@ -163,14 +155,6 @@ public:
virtual void disableReadOnly();
void setTopDir(const std::string& topDir) {
this->topDir = topDir;
}
const std::string& getTopDir() const {
return topDir;
}
void setPieceLength(size_t pieceLength) {
this->pieceLength = pieceLength;
}

View file

@ -276,7 +276,7 @@ void RequestGroup::createInitialCommand(std::deque<Command*>& commands,
progressInfoFile->removeFile();
_logger->notice(MSG_REMOVED_DEFUNCT_CONTROL_FILE,
progressInfoFile->getFilename().c_str(),
_pieceStorage->getDiskAdaptor()->getFilePath().c_str());
getFilePath().c_str());
}
// First, make DiskAdaptor read-only mode.
_pieceStorage->getDiskAdaptor()->enableReadOnly();
@ -295,7 +295,7 @@ void RequestGroup::createInitialCommand(std::deque<Command*>& commands,
throw DownloadFailureException
(StringFormat
(MSG_FILE_ALREADY_EXISTS,
_pieceStorage->getDiskAdaptor()->getFilePath().c_str()).str());
getFilePath().c_str()).str());
} else {
_pieceStorage->getDiskAdaptor()->openFile();
}
@ -443,7 +443,7 @@ void RequestGroup::loadAndOpenFile(const BtProgressInfoFileHandle& progressInfoF
progressInfoFile->removeFile();
_logger->notice(MSG_REMOVED_DEFUNCT_CONTROL_FILE,
progressInfoFile->getFilename().c_str(),
_pieceStorage->getDiskAdaptor()->getFilePath().c_str());
getFilePath().c_str());
}
while(1) {
if(progressInfoFile->exists()) {

View file

@ -107,9 +107,4 @@ void SingleFileDownloadContext::markTotalLengthIsUnknown()
_knowsTotalLength = false;
}
const std::string& SingleFileDownloadContext::getName() const
{
return _fileEntry->getPath();
}
} // namespace aria2

View file

@ -97,8 +97,6 @@ public:
virtual std::deque<SharedHandle<FileEntry> > getFileEntries() const;
virtual const std::string& getName() const;
virtual size_t getPieceLength() const
{
return _pieceLength;

View file

@ -32,7 +32,6 @@ public:
adaptor.reset(new MultiDiskAdaptor());
adaptor->setPieceLength(2);
adaptor->setStoreDir(".");
adaptor->setTopDir(".");
}
void testWriteData();