irfhzk
V2EX  ›  问与答

android/Kotlin: 下载完的文件今后如何保持和服务器文件版本一致?

  •  
  •   irfhzk · Oct 5, 2020 · 1784 views
    This topic created in 2073 days ago, the information mentioned may be changed or developed.

    我的 App 因为有离线使用要求, 必须从服务器下载大量文件. 请问有什么比较简单高效的方案能确保下载完的文件今后和服务器文件版本一致?

    谢谢!!

    3 replies    2020-10-05 18:59:59 +08:00
    6IbA2bj5ip3tK49j
        1
    6IbA2bj5ip3tK49j  
       Oct 5, 2020
    md5 之类的 hash 对比呗。
    zoharSoul
        2
    zoharSoul  
       Oct 5, 2020
    效验 md5
    imdong
        3
    imdong  
       Oct 5, 2020
    对每个文件的 hash 保存在一个文件,然后把这个清单文件的 hash 与服务器对比。

    如果不一致,就下载最新的 hash 对应的清单文件,在逐个对比本地文件,将不一样的文件更新即可。

    额外建议:所有文件包括列表都是用 hash 值作为文件名。

    1e/cf2d....
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5429 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 06:04 · PVG 14:04 · LAX 23:04 · JFK 02:04
    ♥ Do have faith in what you're doing.