当我的文件和/或他们的文件发生更改时,安装程​​序/SVN 用于部署应用程序数据文件

发布于 2024-10-15 15:37:23 字数 454 浏览 1 评论 0原文

我对 Tortoise SVN / Innosetup 的使用感到一团糟,并且我自己对尝试保留客户数据更改感到自豪,并且希望得到一些建议。问题是:

我部署了一个安装其数据文件的应用程序,并且作为安装的一部分,我让安装程序将这些文件标记为“神奇”日期时间(01-01-1991 00:00:00)。我的客户随后会修改一些数据文件,导致它们的日期比我的“神奇”日期更新。因为我不想丢弃客户更改,所以我在 Innosetup 中使用“COMPARETIMESTAMP”(尽管“不推荐”)。这一直很有效,直到我必须将更改部署到我的一个文件,在这种情况下,除非客户更改了时间戳,否则我需要忽略时间戳。

这种情况适用于所有文件类型,例如没有版本功能、只有日期时间的文本文件。

作为进一步的限制,我的日期时间标记必须发生在安装程序脚本中,因为 SVN 不(也不应该)保证稍后的文件日期时间。

我在这里缺少更好的方法吗?其他人对此做了什么? 谢谢

I'm getting in a mess with the use of Tortoise SVN / Innosetup and my own pride in trying to preserve customer 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

巨坚强 2024-10-22 15:37:23

好吧,我寻求这个问题的答案,并提出了这个方法,我在这里复制了它,以防它有一些用处。它的作用是:

  1. 如果目标文件已被最终用户修改,则显示一条消息,默认情况下不理会它。

  2. 如果最终用户未修改目标文件,请始终替换它。

要实现此目的,您需要使用脚本设置:

[Setup]

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

安装时,所有“我的”文件都被标记为 1/1/1991 01:01,这对于检查很有用,并允许我使用以下两行在最终用户可以编辑的任何文件的 [Files] 部分中,例如:

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

两行都尝试安装该文件,但如果使用检查功能该文件仍然是“我的一个”,则第二行将使用差异标志安装该文件“是魔法”。 'IsMagic 函数在代码中声明如下:

[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;
// ------------------------------------------------------------------------------------

我希望这有一些用处。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文