Skip to content

Commit c21408c

Browse files
committed
Fix #776
1 parent 8178ce8 commit c21408c

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

extensions/scripting/lua-bindings/manual/network/lua_downloader.cpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
THE SOFTWARE.
2323
****************************************************************************/
2424
#include "lua_downloader.h"
25+
#include "scripting/lua-bindings/manual/CCLuaValue.h"
2526

2627
#include "network/CCDownloader.h"
2728
#include <iostream>
@@ -171,22 +172,35 @@ static int lua_downloader_createDownloadFileTask(lua_State* L)
171172
{
172173
int argc = lua_gettop(L) - 1;
173174
Downloader* d = checkDownloader(L);
174-
std::string url = "";
175-
std::string storagePath = "";
176-
std::string identifier = "";
175+
std::string_view url = ""sv;
176+
std::string_view storagePath = ""sv;
177+
std::string_view identifier = ""sv;
177178

178179
if (argc < 2)
179180
{
180181
luaL_error(L, "ax.Downloader.createDownloadFileTask parameter error!");
181182
return 0;
182183
}
183184

184-
url = lua_tostring(L, 2);
185-
storagePath = lua_tostring(L, 3);
185+
url = axislua_tosv(L, 2);
186+
storagePath = axislua_tosv(L, 3);
186187
if (argc > 2)
187-
identifier = lua_tostring(L, 4);
188+
identifier = axislua_tosv(L, 4);
188189

189-
auto tsk = d->createDownloadFileTask(url, storagePath, identifier);
190+
std::string_view md5checksum = ""sv;
191+
std::string_view cacertPath = ""sv;
192+
bool background = false;
193+
194+
if (argc > 3)
195+
md5checksum = axislua_tosv(L, 5);
196+
197+
if (argc > 4)
198+
background = lua_toboolean(L, 6);
199+
200+
if (argc > 5)
201+
cacertPath = axislua_tosv(L, 7);
202+
203+
auto tsk = d->createDownloadFileTask(url, storagePath, identifier, md5checksum, background, cacertPath);
190204

191205
pushTaskTable(L, *tsk);
192206
return 1;

0 commit comments

Comments
 (0)