From 849a533d61d29fe00d6499caeb848fb6ee3dec62 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 10 Mar 2009 12:24:29 +0000 Subject: [PATCH] 2009-03-10 Tatsuhiro Tsujikawa 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 --- ChangeLog | 23 +++++++++++++++++++++++ src/AbstractSingleDiskAdaptor.h | 2 ++ src/BtContext.h | 2 ++ src/DefaultPieceStorage.cc | 4 +--- src/DiskAdaptor.h | 2 -- src/DownloadContext.h | 2 -- src/MultiDiskAdaptor.cc | 8 -------- src/MultiDiskAdaptor.h | 16 ---------------- src/RequestGroup.cc | 6 +++--- src/SingleFileDownloadContext.cc | 5 ----- src/SingleFileDownloadContext.h | 2 -- test/MultiDiskAdaptorTest.cc | 1 - 12 files changed, 31 insertions(+), 42 deletions(-) diff --git a/ChangeLog b/ChangeLog index af0e23e0..3e4f06c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2009-03-10 Tatsuhiro Tsujikawa + + 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 FileEntry::getPath() contains store(top level) directory to diff --git a/src/AbstractSingleDiskAdaptor.h b/src/AbstractSingleDiskAdaptor.h index fd16d585..b01f29a2 100644 --- a/src/AbstractSingleDiskAdaptor.h +++ b/src/AbstractSingleDiskAdaptor.h @@ -86,6 +86,8 @@ public: virtual void cutTrailingGarbage(); + virtual std::string getFilePath() = 0; + void setDiskWriter(const SharedHandle& diskWriter); SharedHandle getDiskWriter() const; diff --git a/src/BtContext.h b/src/BtContext.h index 6a7f629e..334d33f7 100644 --- a/src/BtContext.h +++ b/src/BtContext.h @@ -85,6 +85,8 @@ public: virtual std::deque >& getNodes() = 0; + virtual const std::string& getName() const = 0; + void setFileFilter(const IntSequence& seq); IntSequence getFileFilter() const; diff --git a/src/DefaultPieceStorage.cc b/src/DefaultPieceStorage.cc index 4783045e..ba86f1e4 100644 --- a/src/DefaultPieceStorage.cc +++ b/src/DefaultPieceStorage.cc @@ -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; } } diff --git a/src/DiskAdaptor.h b/src/DiskAdaptor.h index 9b4fb1a7..307ce155 100644 --- a/src/DiskAdaptor.h +++ b/src/DiskAdaptor.h @@ -67,8 +67,6 @@ public: virtual bool fileExists() = 0; - virtual std::string getFilePath() = 0; - virtual uint64_t size() = 0; // optional behavior diff --git a/src/DownloadContext.h b/src/DownloadContext.h index 9440f905..a07a42c7 100644 --- a/src/DownloadContext.h +++ b/src/DownloadContext.h @@ -81,8 +81,6 @@ public: virtual std::deque > getFileEntries() const = 0; - virtual const std::string& getName() const = 0; - virtual size_t getPieceLength() const = 0; virtual size_t getNumPieces() const = 0; diff --git a/src/MultiDiskAdaptor.cc b/src/MultiDiskAdaptor.cc index 142997ce..a1b33d34 100644 --- a/src/MultiDiskAdaptor.cc +++ b/src/MultiDiskAdaptor.cc @@ -282,11 +282,6 @@ void MultiDiskAdaptor::resetDiskWriterEntries() } } -std::string MultiDiskAdaptor::getTopDirPath() const -{ - return storeDir+"/"+topDir; -} - void MultiDiskAdaptor::mkdir() const { for(std::deque >::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 >::iterator i = fileEntries.begin(); i != fileEntries.end(); ++i) { if(File((*i)->getPath()).exists()) { diff --git a/src/MultiDiskAdaptor.h b/src/MultiDiskAdaptor.h index d8f96e87..ae9695e7 100644 --- a/src/MultiDiskAdaptor.h +++ b/src/MultiDiskAdaptor.h @@ -101,7 +101,6 @@ typedef std::deque 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& 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(); @@ -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; } diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc index 0cae133e..8a12fe23 100644 --- a/src/RequestGroup.cc +++ b/src/RequestGroup.cc @@ -276,7 +276,7 @@ void RequestGroup::createInitialCommand(std::deque& 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& 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()) { diff --git a/src/SingleFileDownloadContext.cc b/src/SingleFileDownloadContext.cc index 00edd233..3e2c2f35 100644 --- a/src/SingleFileDownloadContext.cc +++ b/src/SingleFileDownloadContext.cc @@ -107,9 +107,4 @@ void SingleFileDownloadContext::markTotalLengthIsUnknown() _knowsTotalLength = false; } -const std::string& SingleFileDownloadContext::getName() const -{ - return _fileEntry->getPath(); -} - } // namespace aria2 diff --git a/src/SingleFileDownloadContext.h b/src/SingleFileDownloadContext.h index 247b07f9..6a254c88 100644 --- a/src/SingleFileDownloadContext.h +++ b/src/SingleFileDownloadContext.h @@ -97,8 +97,6 @@ public: virtual std::deque > getFileEntries() const; - virtual const std::string& getName() const; - virtual size_t getPieceLength() const { return _pieceLength; diff --git a/test/MultiDiskAdaptorTest.cc b/test/MultiDiskAdaptorTest.cc index 83c282aa..407903cf 100644 --- a/test/MultiDiskAdaptorTest.cc +++ b/test/MultiDiskAdaptorTest.cc @@ -32,7 +32,6 @@ public: adaptor.reset(new MultiDiskAdaptor()); adaptor->setPieceLength(2); adaptor->setStoreDir("."); - adaptor->setTopDir("."); } void testWriteData();