自动更新 ala Google Chrome 工作流程
在我所在的公司,我被要求编写一个 chrome 的自动更新功能。即它应该定期检查是否有新版本可用,下载新版本并在下次应用程序启动时静默应用它。
我已经有一些东西正在运行,但它更像是一个肮脏的黑客而不是我对此感到高兴的东西。所以,我想知道如何设计和实现这样的解决方案。我可怕的黑客工作原理如下:
有一个机制来检查新版本是否存在(数据库查询或 Web 服务)
下载包含全新版本的完整 zip 文件。
检查文件签名。如果一切正常,请设置注册表值:必须更新为 true。
当应用程序重新启动时,如果必须更新值为 true,则启动更新程序并存在。
更新删除应用程序文件夹的内容,解压缩更新并替换旧内容,启动应用程序并退出。
更新
现在,我想改变它,让它工作得更干净。我计划将更新作为 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:
Have a mechanism to check whether a new version exists (a database query or a web service)
Download a full zip with the whole new version.
Check file signature. If everything went alright, set a registry value: must update to true.
When the application restarts, if the must update value is true, launch an update program and exist.
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您实际上可以通过 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.
如果您选择 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.
您提出的工作流程或多或少就像它应该工作的那样,但没有必要重新发明轮子 - 有很多库可以为您做到这一点。使用第三方库的好处是可以保持代码整洁,同时确保自动更新的脏过程得到控制并完美运行。
相信我,我知道。我是 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).
因此,经过一番研究后,这就是我带来的(对于活动目录,我将指主程序所在的目录,活动程序是主程序,更新程序是替换活动程序的程序,其资源文件):
当程序退出时(并且必须在此处控制不同的中断):
所以各位,如果您有更好的工作流程,请告诉我。
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):
When a program is exiting (and one has to control for different interrupts here):
So guys, if you have a better workflow, please tell me.