Use Ubot S3 repository for uploading graph files.

This commit is contained in:
jeefo 2020-04-12 17:41:42 +03:00 committed by GitHub
commit b2c8fbd341
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -813,20 +813,14 @@ int BotControl::cmdNodeReleaseEditor () {
}
int BotControl::cmdNodeUpload () {
enum args { graph_cmd = 1, cmd, id, max };
// adding more args to args array, if not enough passed
fixMissingArgs (max);
if (!hasArg (id)) {
return BotCommandResult::BadFormat;
}
enum args { graph_cmd = 1, cmd };
// do not allow to upload bad graph
if (!graph.checkNodes (false)) {
msg ("Sorry, unable to upload graph file that contains errors. Please type \"wp check\" to verify graph consistency.");
return BotCommandResult::BadFormat;
}
msg ("\n");
msg ("WARNING!");
msg ("Graph uploaded to graph database in synchronous mode. That means if graph is big enough");
@ -836,14 +830,10 @@ int BotControl::cmdNodeUpload () {
// six seconds is enough?
http.setTimeout (6);
extern ConVar yb_graph_url;
// try to upload the file
if (http.uploadFile (strings.format ("%s/", yb_graph_url.str ()), strings.format ("%sgraph/%s.graph", graph.getDataDirectory (false), game.getMapName ()))) {
msg ("Graph file was uploaded and Issue Request has been created for review.");
msg ("As soon as database administrator review your upload request, your graph will");
msg ("be available to download for all YaPB users. You can check your issue request at:");
msg ("URL: https://github.com/jeefo/yapb-graph/issues");
if (http.uploadFile ("http://upload.ubot.su/", strings.format ("%sgraph/%s.graph", graph.getDataDirectory (false), game.getMapName ()))) {
msg ("Graph file was successfully validated and uploaded to the Ubot S3 storage (%s).", product.download);
msg ("It will be available for download for all Ubot and YaPB users in a few minutes");
msg ("\n");
msg ("Thank you.");
msg ("\n");
@ -861,8 +851,9 @@ int BotControl::cmdNodeUpload () {
else {
status.assignf ("%d", code);
}
msg ("Something went wrong with uploading. Come back later. (%s)", status.chars ());
msg ("Something went wrong with uploading. Come back later. (%s)", status);
msg ("\n");
if (code == HttpClientResult::Forbidden) {
msg ("You should create issue-request manually for this graph");
msg ("as it's already exists in database, can't overwrite. Sorry...");