自动更新 ala Google Chrome 工作流程

发布于 2024-11-09 04:12:16 字数 618 浏览 0 评论 0原文

在我所在的公司,我被要求编写一个 chrome 的自动更新功能。即它应该定期检查是否有新版本可用,下载新版本并在下次应用程序启动时静默应用它。

我已经有一些东西正在运行,但它更像是一个肮脏的黑客而不是我对此感到高兴的东西。所以,我想知道如何设计和实现这样的解决方案。我可怕的黑客工作原理如下:

  1. 有一个机制来检查新版本是否存在(数据库查询或 Web 服务)

  2. 下载包含全新版本的完整 zip 文件。

  3. 检查文件签名。如果一切正常,请设置注册表值:必须更新为 true。

  4. 当应用程序重新启动时,如果必须更新值为 true,则启动更新程序并存在。

  5. 更新删除应用程序文件夹的内容,解压缩更新并替换旧内容,启动应用程序并退出。

    更新

现在,我想改变它,让它工作得更干净。我计划将更新作为 bsdiff 文件发送。它被下载。但问题是,接下来会发生什么?

什么时候应用更新? 谁负责应用补丁?是程序本身还是第三个程序,就像我一样,负责应用补丁并重新启动应用程序?

In the company I am I was asked to write an autoupdate function a la chrome. I.e. It should check periodically whether a new version is available, download the new version and apply it silently the next time the application starts.

I already have something up and running but it is more like a dirty hack than something I feel happy about it. So, I would like to know how to design and implement such a solution. My horrible hack works as this:

  1. Have a mechanism to check whether a new version exists (a database query or a web service)

  2. Download a full zip with the whole new version.

  3. Check file signature. If everything went alright, set a registry value: must update to true.

  4. When the application restarts, if the must update value is true, launch an update program and exist.

  5. The update deletes the contents of the application folder, unzips the update and replaces the old contents, launches the application and exits.

Now, I would like to change it, so it works cleaner. I am planning to send the update as a bsdiff file. It gets downloaded. But the question is, what happens next?

When do apply the update?
Who is in charge of applying the patch? is it the program itself or is it a third program, as I did, which is in charge of applying the patch and relaunch the application?

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

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

发布评论

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

评论(4

始终不够 2024-11-16 04:12:17

您实际上可以通过 Google Chrome 更新程序来使用 Google Chrome 更新工作流程:

http://code.google。 com/p/omaha/

他们于 2009 年 2 月将其开源。

You could literally use the Google Chrome update workflow by using the Google Chrome updater:

http://code.google.com/p/omaha/

They open sourced it Feb 2009.

℡寂寞咖啡 2024-11-16 04:12:16

如果您选择 C++ 路线,您可以访问 chromium 并下载 Chrome 源代码并深入了解如何更新已完成,这可能会让您更好地了解如何处理它。这是一篇可能有帮助的文章

如果您熟悉 .NET,最近发布的 nuget 还有一个可能有用的自动更新功能,您可以从 这里。 David Ebbo 在这里。

我不太了解 Delphi,但您也许可以使用上述任一选项。

If your going down the C++ route you can go to chromium and download the Chrome source code and dig around to see how the update is done, this might give you a better idea on how to approach it. Here's an article that might help.

If your familiar with .NET the recently release nuget also has an auto update feature that might be useful to look at, you can get the source code from here. David Ebbo has a blog about how its done here.

I'm not up to date on Delphi but you might be able to use either of the above options.

心头的小情儿 2024-11-16 04:12:16

您提出的工作流程或多或少就像它应该工作的那样,但没有必要重新发明轮子 - 有很多库可以为您做到这一点。使用第三方库的好处是可以保持代码整洁,同时确保自动更新的脏过程得到控制并完美运行。

相信我,我知道。我是 NAppUpdate 的作者,这是一个 .NET 应用程序更新框架(您可能想尝试一下)或借鉴)。

The workflow you proposed is more or less like it should work, but there's no need to re-invent the wheel - there are plenty libraries out there that will do this for you. Using a 3rd party library has the benefit of keeping your code cleaner while making sure the dirty process of auto-update is contained and working flawlessly.

Trust me, I know. I'm the author of NAppUpdate, an app update framework for .NET (which you might want to try out or learn from).

哆兒滾 2024-11-16 04:12:16

因此,经过一番研究后,这就是我带来的(对于活动目录,我将指主程序所在的目录,活动程序是主程序,更新程序是替换活动程序的程序,其资源文件):

  • 活动程序每隔一定时间检查是否有新版本。如果是这样,请下载它
  • 并在单独的文件夹中准备新版本(这可以通过将程序所在目录的内容复制到子目录并应用二进制补丁,或者简单地解压缩新版本来完成)。
  • 设置一个标志来指示新版本已准备就绪。

当程序退出时(并且必须在此处控制不同的中断):

  • 活动程序检查新版本就绪标志。启动更新程序并退出。
  • 更新程序检查是否可以在活动目录中写入。如果是,则将内容替换为准备好的版本。
  • 更新程序必须重新检查链接并相应地更新它们。

所以各位,如果您有更好的工作流程,请告诉我。

So, after giving it a lot of though, this is what I came with (for active directory I will refer to the directory where the main program lies, active program is the main program and update program is the one that replaces the active program and its resource files):

  • The active program checks if there is a new version every certain amount of time. If so, download it
  • Prepare new version in a separate folder (this can be done by copying the contents of the directory with the program to a subdirectory and applying a binary patch, or simply unziping the new version).
  • Set a flag that indicates that a new version is ready.

When a program is exiting (and one has to control for different interrupts here):

  • The active program checks the new version ready flag. Launch the update program and exit.
  • The update program checks if it can write in the active directory. If so, replaces the contents with the prepared version.
  • The update program has to recheck links and update them accordingly.

So guys, if you have a better workflow, please tell me.

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