Skip to content

Commit b01d71a

Browse files
committed
Improve manifest revision hash
1 parent b886298 commit b01d71a

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

src/core/cb.offline/main.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ var glob = require("glob");
33
var path = require('path');
44
var Q = require('q');
55
var Manifest = require('./manifest').Manifest;
6+
var pkg = require('../../../package.json');
7+
var crypto = require('cryptojs').Crypto;
68

79
function setup(options, imports, register) {
810
var server = imports.server;
@@ -18,16 +20,17 @@ function setup(options, imports, register) {
1820
server.app.get("/manifest.appcache", function(req, res) {
1921
res.header("Content-Type", "text/cache-manifest");
2022

23+
addons.list().then(function(installedAddons) {
24+
var revision = pkg.version+"-"+crypto.MD5(_.map(installedAddons, function(addon, addonName) {
25+
return addonName;
26+
}).sort().join("-")).toString();
2127

22-
manifest.clear().then(function() {
28+
// Clear manifest
29+
return manifest.clear(revision);
30+
}).then(function() {
2331
// Add network
2432
manifest.add("NETWORK", [
25-
'*',
26-
/* '/rpc',
27-
'/vfs',
28-
'/export',
29-
'/socket.io',
30-
'/proxy' */
33+
'*'
3134
]);
3235

3336
// Add static files

src/core/cb.offline/manifest.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ var path = require('path');
44
var Q = require('q');
55

66
var Manifest = function() {
7+
this.revision = 0;
8+
79
// Regenerate manifest
8-
this.clear = function(regenerate) {
9-
if (regenerate) this.startTime = Date.now();
10+
this.clear = function(revision) {
11+
if (revision) this.revision = revision;
1012
this.sections = {
1113
'CACHE': {},
1214
'NETWORK': {},
@@ -52,7 +54,7 @@ var Manifest = function() {
5254
this.content = function() {
5355
var lines = [
5456
"CACHE MANIFEST",
55-
"# Revision "+this.startTime
57+
"# Revision "+this.revision
5658
];
5759

5860
_.each(this.sections, function(content, section) {
@@ -65,7 +67,7 @@ var Manifest = function() {
6567
return Q(lines.join("\n"));
6668
};
6769

68-
this.clear(true);
70+
this.clear(Date.now());
6971
};
7072

7173
exports.Manifest = Manifest;

0 commit comments

Comments
 (0)