瀏覽代碼

Fix bug that file name is not logged with --conditional-get

Tatsuhiro Tsujikawa 9 年之前
父節點
當前提交
a31e73d902
共有 1 個文件被更改,包括 13 次插入0 次删除
  1. 13 0
      src/HttpResponseCommand.cc

+ 13 - 0
src/HttpResponseCommand.cc

@@ -184,6 +184,19 @@ bool HttpResponseCommand::executeInternal()
     getPieceStorage()->markAllPiecesDone();
     // Just set checksum verification done.
     ctx->setChecksumVerified(true);
+
+    if (fe->getPath().empty()) {
+      // If path is empty, set default file name or file portion of
+      // URI.  This is the file we used to get modified date.
+      auto& file = getRequest()->getFile();
+      auto suffixPath = util::createSafePath(
+          getRequest()->getFile().empty()
+              ? Request::DEFAULT_FILE
+              : util::percentDecode(std::begin(file), std::end(file)));
+      fe->setPath(util::applyDir(getOption()->get(PREF_DIR), suffixPath));
+      fe->setSuffixPath(suffixPath);
+    }
+
     A2_LOG_NOTICE(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
                       GroupId::toHex(grp->getGID()).c_str(),
                       grp->getFirstFilePath().c_str()));