Skip to content

Commit

Permalink
Bugfix (cmdline): delete a created file in case of download errors
Browse files Browse the repository at this point in the history
  • Loading branch information
deniskovalchuk committed Sep 16, 2023
1 parent afa0851 commit 680f9c9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/cmdline/src/command_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,13 @@ void command_handler::get(const std::vector<std::string> & 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<std::string> & args)
Expand Down

0 comments on commit 680f9c9

Please sign in to comment.