diff --git a/src/cgi.cpp b/src/cgi.cpp index c90437f..c716c09 100644 --- a/src/cgi.cpp +++ b/src/cgi.cpp @@ -1,5 +1,5 @@ /* This file is part of FediBlock-backend. - * Copyright © 2020 tastytea + * Copyright © 2020, 2021 tastytea * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -18,6 +18,7 @@ #include "files.hpp" #include "fs-compat.hpp" +#include "git.hpp" #include "time.hpp" #include @@ -27,6 +28,7 @@ #include #include +#include #include #include #include @@ -67,6 +69,7 @@ entry_type parse_formdata() entry.description = cgi("description"); entry.report_time = time::to_string(system_clock::now()); + std::uint8_t screenshot_counter{1}; for (const auto &screenshot : cgi.getFiles()) { constexpr size_t size_limit{1024 * 512}; @@ -78,7 +81,11 @@ entry_type parse_formdata() size_limit / 1024.0)}; } - const string filepath{files::get_tmpdir() / screenshot.getFilename()}; + const string filepath{ + files::get_tmpdir() + / format("{:s}-{:s}{:s}", git::get_branch_name(), + screenshot_counter, + fs::path(screenshot.getFilename()).extension().string())}; ofstream file{filepath, ios::binary}; if (!file.good()) { @@ -86,6 +93,7 @@ entry_type parse_formdata() } screenshot.writeToStream(file); entry.screenshot_filepaths.push_back(filepath); + ++screenshot_counter; } return entry;