我应该如何实现自动更新程序? [英] How should I implement an auto-updater?

查看:228
本文介绍了我应该如何实现自动更新程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

许多程序都包含一个自动更新程序,该程序有时会在网上查找更新,然后下载并应用找到的所有更新.程序错误已修复,支持文件已修改,并且(通常)情况有所改善.

Many programs include an auto-updater, where the program occasionally looks online for updates, and then downloads and applies any updates that are found. Program bugs are fixed, supporting files are modified, and things are (usually) made better.

不幸的是,无论我多么努力,都无法在任何地方找到有关此过程的信息.似乎已实施的自动更新程序是专有的,或者不重要.

Unfortunately no matter how hard I look, I can't find information on this process anywhere. It seems like the auto-updaters that have been implemented have either been proprietary or not considered important.

实施在网络上查找更新并下载更新的系统似乎相当容易.自动更新的那部分将在实现之间发生重大变化.问题是应用补丁有哪些不同的方法.只是下载文件并用新文件替换旧文件,运行已下载的迁移脚本,对系统的某些部分进行猴子修补等?概念是首选,但希望使用Java,C,Python,Ruby,Lisp等示例.

It seems fairly easy to implement the system that looks for updates on a network and downloads them if they are available. That part of the auto-updater will change significantly from implementation to implementation. The question is what are the different approaches of applying patches. Just downloading files and replacing old ones with new ones, running a migration script that was downloaded, monkey patching parts of the system, etc.? Concepts are preferred, but examples in Java, C, Python, Ruby, Lisp, etc. would be appreciated.

推荐答案

我认为不可知的语言"在这里将是一个限制因素.应用程序的形状和大小是如此之多,以至于没有一种千篇一律"的答案.我已经用几种语言实现了几个自动更新器,没有两个是相似的.

I think that "language agnostic" is going to be a limiting factor here. Applications come in so many shapes and sizes that there is no one-size-fits-all answer. I have implemented several auto-updaters in several languages, and no two were similar.

最普遍的理念是,应用程序会检查一些家庭位置(网址,网络查询,公司网络位置等),以询问其当前版本或最新版本.如果答案需要更新,则每种情况下的处理过程都会有所不同.

The most general philosophy is that the application checks with some home location (web address, web query, corporate network location, etc.) to either ask if it's version is current, or ask what the most current version is. If the answer calls for an update, that process will be different for each situation.

一种流行的替代方法是在应用程序启动时邀请家乡位置运行脚本.例如,该脚本可以检查版本,下载更新,并要求使用反馈.

A popular alternative is to invite the home location to run a script when the application is initiated. The script can check the version, download updates if necessary, and ask for usage feedback, for example.

如果您缩小参数范围,我们可能会更好地提供帮助.

We can probably help better if you narrow the parameters.

更新:修补"的方法还取决于应用程序的性质,并且这里有非常广泛的多样性.例如,如果您只有一个可执行文件,则替换可执行文件可能是最实际的.如果您的应用程序包含许多文件,则应寻找减少替换文件数量的方法.如果您的应用程序是高度定制的或参数化的,则应努力减少重新定制工作.如果您的应用程序使用解释后的代码(例如Excel VBA应用程序或MS Access MDB应用程序),则您可以替换部分代码.在Java应用程序中,您可能只需要替换JAR文件,甚至是JAR内容的子集.您还需要一种方法来识别当前的客户端版本,并进行适当的更新.我可以继续下去,但我希望你能看到我关于多样性的观点.这是最佳答案通常以嗯,取决于...!"开头的许多次之一.这就是为什么这么多答案都包括请缩小参数范围"的原因.

UPDATE: The approach to "patching" also depends on the nature of the application, and there's a very wide diversity here. If you have a single executable file, for instance, then it's probably most practical to replace the executable. If your application has many files, you should look for ways to minimize the number of files replaced. If your application is highly customized or parameterized, you should strive to minimize the re-tailoring effort. If your application employs interpreted code (such as an Excel VBA application or MS Access MDB application), then you may be able to replace parts of the code. In a Java application you may only need to replace a JAR file, or even a subset of the JAR contents. You'll also need to have a way to recognize the current client version, and update it appropriately. I could go on and on, but I hope you see my point about diversity. This is one of those many times when the best answer usually starts with "Well, it depends ...!" That's why so many answers include "Please narrow the parameters."

这篇关于我应该如何实现自动更新程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆