如何应用程序启动自动更新? [英] How does an application launcher update itself?

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

问题描述

发射器是最常见的游戏。觉得英雄联盟,星际争霸2的,或几乎所有的网络游戏在那里。在开始实际比赛之前,你有一个小型发射器的应用程序,负责更新和打补丁的。

Launchers are most common in games. Think of League of Legends, Starcraft II, or almost any MMO out there. Before starting the actual game, you have a small launcher app that takes care of updates and patching.

我要与特定的非游戏应用程序,我提出这个方向发展。发射器的概念是完全有道理的:它检查更新,替换相应的二进制文件/库,可能运行的完整性检查,并启动应用程序。然而,如何发射更新自己呢?这往往是一个罕见事件,但它是怎么做的?是否发射字面上只是写在它正在运行的非常二进制?或者是有一些下载后交换步骤?我需要能够(罕见)更新推送到发射器(尤其是当我发现在我启动了一些bug)。

I want to move this direction with a particular non-game application I am developing. The concept of the launcher makes perfect sense: it checks for updates, replaces the appropriate binaries/libraries, maybe runs an integrity check, and launches the application. However, how do launchers update themselves? This tends to be a rare event, but how is it done? Does the launcher literally just write over the very binary it is currently running from? Or is there some kind of swap step after the download? I need to be able to push out (rare) updates to the launcher (especially if I discover some bug in my launcher).

我的具体项目将在C#中,但我感兴趣的是概念上类似于C ++和/或Java的解决方案,以及以备将来参考。

My particular project will be in C#, but I am interested in conceptually similar C++ and/or Java solutions as well for future reference.

推荐答案

我从来没有尝试过,但是这是我猜(假设你不能覆盖文件执行。如果可以的话,这都是简单)

I've never tried, but this is what I would guess (assuming you can't overwrite a file being executed. If you can, this is all simpler)

Updater A checks if its the newest version
If launcher isnt the newest version
    Download the differences (to save bandwidth) to file B
    Apply the delta to own code into file C
    Launch file C.
    Close
If file C exists (update happened recently)
    Try to delete C  (update was previous launch, delete temporary file)
    If delete fails  (We are C, means A is out of date)
        Copy C over A  (update launcher)
        Note that you can keep going, don't have to restart even though we are C.
If game isnt newest version
    Download the differences (to save bandwidth) to file B
    Apply the delta to game into file D
    delete game
    Rename D -> game
Run game

安德烈卡隆指示我,交换诀窍是用做的事务性文件IO

André Caron has shown me that the swap trick is done better with transactional file IO.

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

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