Search code examples
downloadnsis

NSIS inetc multiple file cancel


I'm using the INETC plugin for NSIS to download multiple files (50+)

Everything seems to be working fine except for one little annoyance at this point

When you get to the part where the files are being downloaded, you are unable to abort the installer.

The 'X' at the top right hand of the Installer (windows close) is greyed out. The INETC plugin itself has a 'cancel' button, but this only cancels the download of the current file, causing the installation package to resume to the next.. With +50 files in queue, this is an annoyance and the only way to get around it is to End Task the process

To call INETC::get i have created a function called DownloadFile which does some validations and takes a filename as an argument

I then call it in the following manner

Strcpy $BatchFile "filename.fileextension"
Call DownloadFile

Essentially, i'd like to know how I can use INETC to download multiple files while not preventing the user from being able to abort the installation entirely

EDIT: DownloadFile code

Function DownloadFile

 IfFileExists "$EXEDIR\$Targetfolder\$BatchFile" +1
 md5dll::GetMD5File "$EXEDIR\$Targetfolder\$BatchFile"
 Pop $0
 Strcpy $MD5file $0

 push "$EXEDIR\$Targetfolder\$BatchFile"
 Push "\"
 Call GetAfterChar
 Pop $R0
 Strcpy $Filename $R0

 push $Filename
 call GetBaseName
 Pop $2
 Strcpy $NoEXTFile $2

 ${If} $NoEXTFILE != $MD5file
   SetDetailsView show
   Detailprint "File $Batchfile doesnt exit or MD5 is faulty. Re-downloading"
   inetc::get /RESUME "Do you want to retry?" "[url]/$BatchFile" "$EXEDIR\$Targetfolder\$BatchFile"
 ${Else}
   Detailprint "File $BatchFile exists, MD5 is good"
 ${EndIf}

 sleep 2000

FunctionEnd

Solution

  • Call inetc::get in a loop, once for each file. If the return value you popped off the stack is not "OK" then abort the loop.