You are here

Preserved file is being overwritten

11 posts / 0 new
Last post
orschiro
Offline
Last seen: 8 years 5 months ago
Joined: 2012-01-07 14:42
Preserved file is being overwritten

Hello,

I need to modify a file of a program called 'profile' which is located in '\AppPortable\App\AppName\folder'.

In order to avoid that my modified 'profile' is being overwritten by the original one I added the following to my installer.ini:

[FilesToPreserve]
PreserveFile1=App\AppName\folder\profile

I want to create an online installer which downloads the source code and extracts it to \App\AppName:

AdvancedExtract1To=App\AppName
AdvancedExtract1Filter=*

So, how can I avoid that the modified 'profile' file which I put in \App\AppName\folder gets overwritten during the installation?

John T. Haller
John T. Haller's picture
Online
Last seen: 43 min 31 sec ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Preserve

Preserve is intended to preserve a file in a directory that would otherwise be wiped out. For example, the whole App directory is normally wiped (unless you set an option for it not to be) and it give you the ability to preserve one or more files within it.

It does not prevent a file that is also in your installer from overwriting one that is already there. Everything in the installer should be installed regardless of preserved bits.

If profile contains anything you wish to save between sessions, it should likely be moved back and forth to Data. Remember, App is for the app only, no settings, etc.

Sometimes, the impossible can become possible, if you're awesome!

orschiro
Offline
Last seen: 8 years 5 months ago
Joined: 2012-01-07 14:42
Thank you. 'profile' is a

Thank you. 'profile' is a app-relevant file and needed for the app to run. However, the modification is necessary to make it portable.

So, the right way is to add something like the following to launcher.ini?

[FilesMove]
profile=%PAL:AppDir%\AppName\folder

Will this move my modified file to App\AppName\folder?

Do I have to place my modified 'profile' in 'DefaultData' when creating the installer?

John T. Haller
John T. Haller's picture
Online
Last seen: 43 min 31 sec ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Yes and Yes

That is the way it would work. But why does it need to have anything done to it post-install? Why not just have it set up for portable use within App before you package the installer and be done with it?

Sometimes, the impossible can become possible, if you're awesome!

orschiro
Offline
Last seen: 8 years 5 months ago
Joined: 2012-01-07 14:42
It's clear now

Because it is an online installer. Thus I cannot modify it before packaging.

But your solution worked out nicely. Thank you!

John T. Haller
John T. Haller's picture
Online
Last seen: 43 min 31 sec ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Write The File

You could also write the file specifically as part of the installer using custom code. That would eliminate the need for a move operation.

Sometimes, the impossible can become possible, if you're awesome!

orschiro
Offline
Last seen: 8 years 5 months ago
Joined: 2012-01-07 14:42
Dcumentation

Can you provide me more information or a documentation on how to do this?

John T. Haller
John T. Haller's picture
Online
Last seen: 43 min 31 sec ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Development Section

The development section includes the PortableApps.com Launcher manual with info on how to write to a file using PAL if you want to do it in the launcher.

To do it in the installer, you could have a copy of the correct file at App\bin\profile that you can copy over at the end of running the installer. You'd have custom code in a PortableApps.comInstallerCustom.nsh file within Other\Source. Something like:

!macro CustomCodePostInstall
    Delete "$INSTDIR\App\AppName\folder\profile"
    CopyFiles /SILENT "$INSTDIR\App\bin\profile" "$INSTDIR\App\AppName\folder"
!macroend

That would delete the profile folder that was extracted from the online installer bit and copy in the proper one at the end of the installer.

Sometimes, the impossible can become possible, if you're awesome!

orschiro
Offline
Last seen: 8 years 5 months ago
Joined: 2012-01-07 14:42
Good idea

Good idea but what about the $INSTDIR\App\bin folder after the copy process? Will this directory be automatically deleted since it is not required?

Or wouldn't it be better to store profile in Other\Source, too?

John T. Haller
John T. Haller's picture
Online
Last seen: 43 min 31 sec ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
App\bin

App\bin is fine and will be ignored from then on. You could name it App\misc if you want as that would be more appropriate. Other\Source is only for source code and associated bits.

Sometimes, the impossible can become possible, if you're awesome!

orschiro
Offline
Last seen: 8 years 5 months ago
Joined: 2012-01-07 14:42
Clear now

Thanks John. I like that solutions and will test it asap.

Log in or register to post comments