Allow aborting the netloader transfer when the user presses B. When decompress() aborts/fails, delete the file. When returning to HBMENU_DEFAULT from netloader, reload the menu since the netloader NRO may have been deleted due to transfer abort/failure. Minor adjustments.
This commit is contained in:
parent
45a10488b1
commit
6d6fb4e3a3
@ -496,7 +496,7 @@ void drawButtons(menu_s* menu, bool emptyDir, int *x_image_out) {
|
||||
void menuLoop(void) {
|
||||
menuEntry_s* me;
|
||||
menuEntry_s* netloader_me = NULL;
|
||||
menu_s* menu = menuGetCurrent();
|
||||
menu_s* menu = NULL;
|
||||
int i;
|
||||
int x, y;
|
||||
int menupath_x_endpos = 918 + 40;
|
||||
@ -539,8 +539,11 @@ void menuLoop(void) {
|
||||
hbmenu_state = HBMENU_NETLOADER_ACTIVE;
|
||||
} else if(hbmenu_state == HBMENU_NETLOADER_ACTIVE && !netloader_activated && !netloader_launch_app) {
|
||||
hbmenu_state = HBMENU_DEFAULT;
|
||||
menuScan(".");//Reload the menu since netloader may have deleted the NRO if the transfer aborted.
|
||||
}
|
||||
|
||||
menu = menuGetCurrent();
|
||||
|
||||
if (netloader_errormsg[0]) menuCreateMsgBox(780,300, netloader_errormsg);
|
||||
|
||||
if (menu->nEntries==0 || hbmenu_state == HBMENU_NETLOADER_ACTIVE)
|
||||
|
@ -51,6 +51,8 @@ static bool netloader_activated = 0, netloader_launchapp = 0;
|
||||
static menuEntry_s netloader_me;
|
||||
static char netloader_errortext[1024];
|
||||
|
||||
static bool netloaderGetExit(void);
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
static void netloader_error(const char *func, int err) {
|
||||
//---------------------------------------------------------------------------------
|
||||
@ -230,6 +232,10 @@ static int decompress(int sock, FILE *fh, size_t filesize) {
|
||||
size_t total = 0;
|
||||
/* decompress until deflate stream ends or end of file */
|
||||
do {
|
||||
if (netloaderGetExit()) {
|
||||
ret = Z_DATA_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
int len = recvall(sock, &chunksize, 4, 0);
|
||||
|
||||
@ -394,6 +400,7 @@ int loadnro(menuEntry_s *me, int sock, struct in_addr remote) {
|
||||
fflush(file);
|
||||
fclose(file);
|
||||
|
||||
if (response == -1) unlink(me->path);
|
||||
}
|
||||
|
||||
return response;
|
||||
@ -600,8 +607,7 @@ void netloaderSignalExit(void) {
|
||||
mtx_unlock(&netloader_mtx);
|
||||
}
|
||||
|
||||
bool netloaderInit(void)
|
||||
{
|
||||
bool netloaderInit(void) {
|
||||
if (netloader_initialized) return 1;
|
||||
|
||||
if (mtx_init(&netloader_mtx, mtx_plain) != thrd_success) return 0;
|
||||
@ -610,17 +616,14 @@ bool netloaderInit(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
void netloaderExit(void)
|
||||
{
|
||||
void netloaderExit(void) {
|
||||
if (!netloader_initialized) return;
|
||||
netloader_initialized = 0;
|
||||
|
||||
mtx_destroy(&netloader_mtx);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
void netloaderTask(void* arg) {
|
||||
//---------------------------------------------------------------------------------
|
||||
int ret=0;
|
||||
menuEntryInit(&netloader_me,ENTRY_TYPE_FILE);
|
||||
|
||||
@ -646,7 +649,7 @@ void netloaderTask(void* arg) {
|
||||
mtx_lock(&netloader_mtx);
|
||||
netloader_exitflag = 0;
|
||||
netloader_activated = 0;
|
||||
if (ret==1) netloader_launchapp = 1;
|
||||
if (ret==1 && !netloader_exitflag) netloader_launchapp = 1;//Access netloader_exitflag directly since the mutex is already locked.
|
||||
mtx_unlock(&netloader_mtx);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user