Rename screenshots to <branch name>-<counter>.<extension>.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
63355e98e7
commit
3cd14347ee
12
src/cgi.cpp
12
src/cgi.cpp
|
@ -1,5 +1,5 @@
|
||||||
/* This file is part of FediBlock-backend.
|
/* This file is part of FediBlock-backend.
|
||||||
* Copyright © 2020 tastytea <tastytea@tastytea.de>
|
* Copyright © 2020, 2021 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include "files.hpp"
|
#include "files.hpp"
|
||||||
#include "fs-compat.hpp"
|
#include "fs-compat.hpp"
|
||||||
|
#include "git.hpp"
|
||||||
#include "time.hpp"
|
#include "time.hpp"
|
||||||
|
|
||||||
#include <cgicc/Cgicc.h>
|
#include <cgicc/Cgicc.h>
|
||||||
|
@ -27,6 +28,7 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <cstdint>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <ios>
|
#include <ios>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -67,6 +69,7 @@ entry_type parse_formdata()
|
||||||
entry.description = cgi("description");
|
entry.description = cgi("description");
|
||||||
entry.report_time = time::to_string(system_clock::now());
|
entry.report_time = time::to_string(system_clock::now());
|
||||||
|
|
||||||
|
std::uint8_t screenshot_counter{1};
|
||||||
for (const auto &screenshot : cgi.getFiles())
|
for (const auto &screenshot : cgi.getFiles())
|
||||||
{
|
{
|
||||||
constexpr size_t size_limit{1024 * 512};
|
constexpr size_t size_limit{1024 * 512};
|
||||||
|
@ -78,7 +81,11 @@ entry_type parse_formdata()
|
||||||
size_limit / 1024.0)};
|
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};
|
ofstream file{filepath, ios::binary};
|
||||||
if (!file.good())
|
if (!file.good())
|
||||||
{
|
{
|
||||||
|
@ -86,6 +93,7 @@ entry_type parse_formdata()
|
||||||
}
|
}
|
||||||
screenshot.writeToStream(file);
|
screenshot.writeToStream(file);
|
||||||
entry.screenshot_filepaths.push_back(filepath);
|
entry.screenshot_filepaths.push_back(filepath);
|
||||||
|
++screenshot_counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
|
|
Reference in New Issue