浏览代码

2007-12-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

	Remove a defunct control file. A defunct control file means that 
while
	it exists, but the corresponding download file is missing.
	After its removal, a download restarts from the beginning.
	* src/RequestGroup.cc
	* src/message.h
Tatsuhiro Tsujikawa 18 年之前
父节点
当前提交
16722b559d
共有 3 个文件被更改,包括 23 次插入0 次删除
  1. 8 0
      ChangeLog
  2. 14 0
      src/RequestGroup.cc
  3. 1 0
      src/message.h

+ 8 - 0
ChangeLog

@@ -1,3 +1,11 @@
+2007-12-27  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	Remove a defunct control file. A defunct control file means that while
+	it exists, but the corresponding download file is missing.
+	After its removal, a download restarts from the beginning.
+	* src/RequestGroup.cc
+	* src/message.h
+
 2007-12-26  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	Allocate bitfield in Peer when it is really used. More specifically,

+ 14 - 0
src/RequestGroup.cc

@@ -192,6 +192,13 @@ Commands RequestGroup::createInitialCommand(DownloadEngine* e)
       BtRegistry::registerPeerObjectCluster(btContext->getInfoHashAsString(),
 					    new PeerObjectCluster());
 
+      // Remove the control file if download file doesn't exist
+      if(progressInfoFile->exists() && !_pieceStorage->getDiskAdaptor()->fileExists()) {
+	progressInfoFile->removeFile();
+	_logger->notice(MSG_REMOVED_DEFUNCT_CONTROL_FILE,
+			progressInfoFile->getFilename().c_str(),
+			_pieceStorage->getDiskAdaptor()->getFilePath().c_str());
+      }
       // Call Load, Save and file allocation command here
       if(progressInfoFile->exists()) {
 	// load .aria2 file if it exists.
@@ -302,6 +309,13 @@ void RequestGroup::loadAndOpenFile(const BtProgressInfoFileHandle& progressInfoF
       _pieceStorage->getDiskAdaptor()->initAndOpenFile();
       return;
     }
+    // Remove the control file if download file doesn't exist
+    if(progressInfoFile->exists() && !_pieceStorage->getDiskAdaptor()->fileExists()) {
+      progressInfoFile->removeFile();
+      _logger->notice(MSG_REMOVED_DEFUNCT_CONTROL_FILE,
+		      progressInfoFile->getFilename().c_str(),
+		      _pieceStorage->getDiskAdaptor()->getFilePath().c_str());
+    }
     if(progressInfoFile->exists()) {
       progressInfoFile->load();
       _pieceStorage->getDiskAdaptor()->openExistingFile();

+ 1 - 0
src/message.h

@@ -133,6 +133,7 @@
 #define MSG_FILE_RENAMED _("File already exists. Renamed to %s.")
 #define MSG_CANNOT_PARSE_METALINK _("Cannot parse metalink XML file. XML may be malformed.")
 #define MSG_TOO_SMALL_PAYLOAD_SIZE _("Too small payload size for %s, size=%d.")
+#define MSG_REMOVED_DEFUNCT_CONTROL_FILE _("Removed the defunct control file %s because the download file %s doesn't exist.")
 
 #define EX_TIME_OUT _("Timeout.")
 #define EX_INVALID_CHUNK_SIZE _("Invalid chunk size.")