From 3453604c4d7ef167554d2e5415bbb79d19b12601 Mon Sep 17 00:00:00 2001 From: ewensun Date: Sun, 30 Nov 2008 21:43:51 +0000 Subject: [PATCH] remove temporary file when cancel file transfer git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@859 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/ft/ftcontroller.cc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/libretroshare/src/ft/ftcontroller.cc b/libretroshare/src/ft/ftcontroller.cc index b60d72a96..b516deab2 100644 --- a/libretroshare/src/ft/ftcontroller.cc +++ b/libretroshare/src/ft/ftcontroller.cc @@ -698,9 +698,28 @@ bool ftController::FileCancel(std::string hash) fc->mCreator = NULL; } - fc->mState = ftFileControl::ERROR_COMPLETION; + /* delete the temporary file */ + if (0 == remove(fc->mCurrentPath.c_str())) + { +#ifdef CONTROL_DEBUG + std::cerr << "ftController::FileCancel() remove temporary file "; + std::cerr << fc->mCurrentPath; + std::cerr << std::endl; +#endif + } + else + { +#ifdef CONTROL_DEBUG + std::cerr << "ftController::FileCancel() fail to remove file "; + std::cerr << fc->mCurrentPath; + std::cerr << std::endl; +#endif + } + + //fc->mState = ftFileControl::ERROR_COMPLETION; mDownloads.erase(mit); + IndicateConfigChanged(); /* completed transfer -> save */ return true; }