2008-09-07 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Implemented the ability to get timestamp from remote HTTP server 
and
	apply it to local file. To enable this feature, --remote-time 
option
	is added. No usage text has been written yet.
	If several servers returns difference timestamp, then aria2 uses 
latest
	one.
	* src/CopyDiskAdaptor.cc
	* src/CopyDiskAdaptor.h
	* src/DirectDiskAdaptor.cc
	* src/DirectDiskAdaptor.h
	* src/DiskAdaptor.h
	* src/File.cc
	* src/File.h
	* src/HttpHeader.cc
	* src/HttpHeader.h
	* src/HttpResponse.cc
	* src/HttpResponse.h
	* src/HttpResponseCommand.cc
	* src/HttpResponseCommand.h
	* src/MultiDiskAdaptor.cc
	* src/MultiDiskAdaptor.h
	* src/OptionHandlerFactory.cc
	* src/RequestGroup.cc
	* src/RequestGroup.h
	* src/RequestGroupMan.cc
	* src/option_processing.cc
	* src/prefs.cc
	* src/prefs.h
	* test/CopyDiskAdaptorTest.cc
	* test/FileTest.cc
	* test/Makefile.am
	* test/Makefile.in
	* test/MultiDiskAdaptorTest.cc
	* test/TestUtil.cc
This commit is contained in:
Tatsuhiro Tsujikawa 2008-09-07 14:38:26 +00:00
parent 4e28efd925
commit dbc8f5b737
29 changed files with 352 additions and 13 deletions

View file

@ -18,6 +18,7 @@ class MultiDiskAdaptorTest:public CppUnit::TestFixture {
CPPUNIT_TEST(testReadData);
CPPUNIT_TEST(testCutTrailingGarbage);
CPPUNIT_TEST(testSize);
CPPUNIT_TEST(testUtime);
CPPUNIT_TEST_SUITE_END();
private:
SharedHandle<MultiDiskAdaptor> adaptor;
@ -33,6 +34,7 @@ public:
void testReadData();
void testCutTrailingGarbage();
void testSize();
void testUtime();
};
@ -181,8 +183,7 @@ void MultiDiskAdaptorTest::testSize()
SharedHandle<FileEntry>(new FileEntry(prefix+"2", 1, 1))
};
for(size_t i = 0; i < arrayLength(entries); ++i) {
createFile(topDirPath+"/"+entries[i]->getPath(),
entries[i]->getLength());
createFile(topDirPath+"/"+entries[i]->getPath(), entries[i]->getLength());
}
std::deque<SharedHandle<FileEntry> > fileEntries
(&entries[0], &entries[arrayLength(entries)]);
@ -199,4 +200,44 @@ void MultiDiskAdaptorTest::testSize()
CPPUNIT_ASSERT_EQUAL((uint64_t)2, adaptor.size());
}
void MultiDiskAdaptorTest::testUtime()
{
std::string storeDir = "/tmp";
std::string topDir = "aria2_MultiDiskAdaptorTest_testUtime";
std::string prefix = storeDir+"/"+topDir;
SharedHandle<FileEntry> entries[] = {
SharedHandle<FileEntry>(new FileEntry("requested", 0, 0)),
SharedHandle<FileEntry>(new FileEntry("notFound", 0, 0)),
SharedHandle<FileEntry>(new FileEntry("notRequested", 0, 0)),
SharedHandle<FileEntry>(new FileEntry("anotherRequested", 0, 0)),
};
createFile(prefix+"/"+entries[0]->getPath(), entries[0]->getLength());
File(prefix+"/"+entries[1]->getPath()).remove();
createFile(prefix+"/"+entries[2]->getPath(), entries[2]->getLength());
createFile(prefix+"/"+entries[3]->getPath(), entries[3]->getLength());
entries[2]->setRequested(false);
std::deque<SharedHandle<FileEntry> > fileEntries
(&entries[0], &entries[arrayLength(entries)]);
MultiDiskAdaptor adaptor;
adaptor.setStoreDir(storeDir);
adaptor.setTopDir(topDir);
adaptor.setFileEntries(fileEntries);
CPPUNIT_ASSERT_EQUAL((size_t)2, adaptor.utime(Time(1000), Time(2000)));
CPPUNIT_ASSERT_EQUAL((time_t)2000,
File(prefix+"/"+entries[0]->getPath())
.getModifiedTime().getTime());
CPPUNIT_ASSERT_EQUAL((time_t)2000,
File(prefix+"/"+entries[3]->getPath())
.getModifiedTime().getTime());
CPPUNIT_ASSERT((time_t)2000 != File(prefix+"/"+entries[2]->getPath())
.getModifiedTime().getTime());
}
} // namespace aria2