NSIS section sizes doubled due to use of SetOverwrite

Viewed 231

I've inherited an installer script, and I'm annoyed by it claiming to require twice as much space as it actually needs.

I found that this was due to how each section is using SetOverwrite (because they're re-used for a repair install?). I understand that it's necessary to keep the duplicated File commands in each of the If/Else blocks because of how SetOverwrite works (see below), but I have confirmed that it results in a doubling of the automatic section size calculations.

${MementoSection} $(APP_Section_SecHelp) SecHelp
  SetDetailsPrint textonly
  DetailPrint  $(APP_DetailPrint_SecHelp)
  SetDetailsPrint listonly

  SetOutPath $INSTDIR
  SectionIn 1 2
    ${If} $SetOverwriteOn == TRUE
      SetOverwrite ifnewer
      File /r "${APP_SOURCE_DIR}\Help"
    ${Else}
      SetOverwrite off
      File /r "${APP_SOURCE_DIR}\Help"
    ${EndIf}
  SectionGetFlags ${SecHelp} $SecHelp_GetFlag
${MementoSectionEnd}

Is this a bad design pattern that I should change? Do I need to add a hack to call SectionGetSize, divide by 2 and call SectionSetSize?

1 Answers
Related