diff --git a/app/cmdline/src/command_handler.cpp b/app/cmdline/src/command_handler.cpp index f83490b..5fd37bb 100644 --- a/app/cmdline/src/command_handler.cpp +++ b/app/cmdline/src/command_handler.cpp @@ -412,7 +412,13 @@ void command_handler::get(const std::vector & args) } transfer_callback transfer_cb; - ftp_client_.download_file(ftp::ostream_adapter(ofs), remote_file, &transfer_cb); + ftp::replies replies = ftp_client_.download_file(ftp::ostream_adapter(ofs), remote_file, &transfer_cb); + + /* Delete the created file in case of errors. */ + if (!replies.is_positive()) + { + std::filesystem::remove(local_file); + } } void command_handler::rename(const std::vector & args)