【问题标题】:Automatic updating of a Chrome extension doesn't workChrome 扩展程序的自动更新不起作用
【发布时间】:2012-04-04 21:47:46
【问题描述】:

我正在尝试实现我的Chrome extension 的自动更新功能。但由于某种原因,它不起作用。我在 GitHub 上托管了一个 updates.xml 文件,我看到它已被下载(下载计数器显示了这一点)。但是扩展程序的latest version 永远不会被下载。

我的manifest.json 看起来像:

"version": "0.14.0",
"update_url": "https://github.com/downloads/PeeHaa/cv-pls/updates.xml",

我的updates.xml 看起来像:

<?xml version='1.0' encoding='UTF-8'?>
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
  <app appid='bcbifciedokdgkokbbfippkbecnkpclj'>
    <updatecheck codebase='https://github.com/downloads/PeeHaa/cv-pls/cv-pls.0.14.0.crx' version='0.14.0' />
  </app>
</gupdate>

我已经检查并再次检查了appid 和下载 URL,它们都是正确的。

有人知道这里出了什么问题吗?它与托管在 GitHub 上的事实有关吗?

【问题讨论】:

标签: google-chrome-extension auto-update


【解决方案1】:

我之前尝试过这种方法,但也失败了。 update.xml 文件已正确下载,但我的应用程序的最新版本无法安装。

我发现它不起作用,因为 github 没有提供正确的标头。如果您查看hosting documentation,内容类型标头应该是“application/x-chrome-extension”。

我刚刚在 php 中编写了一个简单的脚本来为我提供文件:

<?php
$file = "";
header("Content-type: application/x-chrome-extension");
header("Content-Disposition: attachment; filename='extension.crx'");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . filesize($file));
echo readfile($file);
exit;

【讨论】:

  • 我刚刚运行了curl -v --head http://cloud.github.com/downloads/PeeHaa/cv-pls/cv-pls.0.14.0.crx,并且响应中出现了标题Content-Type: application/x-chrome-extension。
【解决方案2】:

看起来 update.xml 和 crx URL 都从 https://github.com 重定向到 https://cloud.github.com。这是我能看到导致更新失败的唯一原因。尝试更新 update.xml 代码库 URL 以包含 cloud。

【讨论】:

  • 仍然是doesn't work。我看到我最新的 updates.xml 被下载了多次,但我没有看到扩展程序本身的任何下载:(
  • 这个周末我要做一些测试,因为它看起来应该可以工作。我知道我以前使用过 Gists 的 update.xml 并且效果很好。如果我不发布更新,请在周日联系我。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-01-19
  • 2012-06-03
  • 2020-05-19
  • 2014-06-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多