开发者

Installer/SVN use to deploy application data files when my file and / or theirs have changed

开发者 https://www.devze.com 2023-02-08 06:22 出处:网络
I\'m getting in a mess with the use of Tortoise SVN / Innosetup and my own pride in trying to preserve cus开发者_高级运维tomer data changes and would appreciate some suggestions. Here\'s the problem:

I'm getting in a mess with the use of Tortoise SVN / Innosetup and my own pride in trying to preserve cus开发者_高级运维tomer data changes and would appreciate some suggestions. Here's the problem:

I deploy an application which installs its data files and as part of the install I've made the installer stamp these files to a 'magic' date-time (01-01-1991 00:00:00). Some data files will be subsequently modifed by my customer causing their date to be more recent than my 'magic' date. Because I dont want to trash customer changes I use 'COMPARETIMESTAMP' in Innosetup (athough its 'not recommended'). This has worked well until I have to deploy a change to one of my files in which case I need the time stamp to be ignored unless the customer has changed it.

This situation applies to all file types e.g text file where there is no version capability, only a date-time.

As a further restriction my stamping of date-time has to happen in the installer script because SVN does not (and should not) guarantee the file date time later.

Am I missing a better approach here? What do others do about this? Thanks


Well, I pursued an answer to this problem and came up with this method which I've reproduced here in case it is of some use. What it does is:

  1. If the destination file has been modified by the end-user, display a message with the default being to leave it alone.

  2. If the destination file HAS NOT been modified by the end-user, always replace it.

To achive this, you need to use the script settings:

[Setup]

; A 'magic' date time
TouchDate=1991-01-01
TouchTime=01:01

When the installation takes place, all 'my' files are stamped to 1/1/1991 01:01 which makes it useful for examination, and allowes me to use the following two lines in the [Files] section for any file which the end-user may edit eg:

[Files]
Source: "...\*.*"; DestDir: <DestDir>; Flags: touch recursesubdirs createallsubdirs overwritereadonly comparetimestamp promptifolder;
Source: "...\*.*"; DestDir: <DestDir>; Flags: touch recursesubdirs  createallsubdirs overwritereadonly; Check: IsMagic;

Both lines attempt to install the file, but the second line installs the file using difference flags if the file is still 'one of mine' using the check function 'IsMagic'. The 'IsMagic function is declared in code as follows:

[Code]

// ------------------------------------------------------------------------------------

function FileNameToLastWriteTime( const AFileName : string ) : TFileTime;
// Returns the file time of the last write to this file
var
  FindRec : TFindRec;
begin
  Result.dwLowDateTime := 0;
  Result.dwHighDateTime := 0;
  try
    If FindFirst( AFileName, FindRec ) then
      Result := FindRec.LastWriteTime;
  finally
    FindClose(FindRec);
  end;
end;

// ------------------------------------------------------------------------------------



// ------------------------------------------------------------------------------------

function IsMagic : boolean;
// This returns TRUE if the file date/time shows it to be an 'ART magic' file, i.e it
// has a date/time stamp that has not been changed by the customer. Typically an ART magic
// file is stamped to '1-1-1991 01:01'. This routine returns TRUE if the current file
// date/time is no later than 31/12/1991 23:59:42.569 corresponding to file time of
// H=28728269, L=0.
var
  Time : TFileTime;
  S : string;
begin
  S := CurrentFileName;
  Time := FileNameToLastWriteTime( S );
  Result := Time.dwHighDateTime <= 28728269;
end;
// ------------------------------------------------------------------------------------

I hope this is of some use.

0

精彩评论

暂无评论...
验证码 换一张
取 消