Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Commit

Permalink
Merge branch 'devel' of https://github.com/Turupawn/modioSDK into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
Turupawn committed Nov 13, 2019
2 parents c9f6e68 + f89246d commit ae97358
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/wrappers/CurlUtility.h
Expand Up @@ -87,6 +87,8 @@ class CurrentModfileUpload
CURL *curl_handle;
struct curl_slist *slist;
struct curl_httppost *httppost;
bool is_temporary_zip_modfile;
std::string zip_modfile_path;

CurrentModfileUpload();
~CurrentModfileUpload();
Expand Down
12 changes: 12 additions & 0 deletions src/wrappers/CurlCallbacks.cpp
Expand Up @@ -129,8 +129,15 @@ void onModfileUploadFinished(CURL *curl)

if (g_current_modfile_upload->queued_modfile_upload->state == MODIO_MOD_UPLOADING)
{
if(g_current_modfile_upload->is_temporary_zip_modfile)
{
writeLogLine("Deleting temporary modfile " + g_current_modfile_upload->zip_modfile_path, MODIO_DEBUGLEVEL_LOG);
modio::removeFile(g_current_modfile_upload->zip_modfile_path);
}

if (modio::upload_callback)
{
writeLogLine("Triggering upload callback listener", MODIO_DEBUGLEVEL_LOG);
modio::upload_callback(response_code, g_current_modfile_upload->queued_modfile_upload->mod_id);
}

Expand All @@ -142,7 +149,12 @@ void onModfileUploadFinished(CURL *curl)

updateModUploadQueueFile();
uploadNextQueuedModfile();
}else
{
writeLogLine("Unhandled error the upload that just finished has the wrong flag: " + modio::toString(g_current_modfile_upload->queued_modfile_upload->state), MODIO_DEBUGLEVEL_ERROR);
}

writeLogLine("Finished handling the modfile upload termination.", MODIO_DEBUGLEVEL_LOG);
updateModUploadQueueFile();
}
} // namespace curlwrapper
Expand Down
4 changes: 4 additions & 0 deletions src/wrappers/CurlWrapper.cpp
Expand Up @@ -546,6 +546,7 @@ void uploadModfile(QueuedModfileUpload *queued_modfile_upload)
std::string modfile_path = queued_modfile_upload->modfile_creator.getModioModfileCreator()->path;

std::string modfile_zip_path = "";
bool is_temporary_zip_modfile = true;

writeLogLine("Uploading mod: " + toString(queued_modfile_upload->mod_id) + " located at path: " + queued_modfile_upload->path, MODIO_DEBUGLEVEL_LOG);

Expand All @@ -559,6 +560,7 @@ void uploadModfile(QueuedModfileUpload *queued_modfile_upload)
{
writeLogLine("Zip file detected: " + modfile_path, MODIO_DEBUGLEVEL_LOG);
modfile_zip_path = modfile_path;
is_temporary_zip_modfile = false;
}else if(modio::fileExists(modfile_path))
{
writeLogLine("File detected " + modfile_path, MODIO_DEBUGLEVEL_LOG);
Expand Down Expand Up @@ -621,6 +623,8 @@ void uploadModfile(QueuedModfileUpload *queued_modfile_upload)

queued_modfile_upload->state = MODIO_MOD_STARTING_UPLOAD;
g_current_modfile_upload->curl_handle = curl;
g_current_modfile_upload->is_temporary_zip_modfile = is_temporary_zip_modfile;
g_current_modfile_upload->zip_modfile_path = modfile_zip_path;
g_current_modfile_upload->queued_modfile_upload = queued_modfile_upload;

for (u32 i = 0; i < modio::getHeaders().size(); i++)
Expand Down

0 comments on commit ae97358

Please sign in to comment.