Skip to content

Commit c8596bc

Browse files
committed
Improve addons loading: load others addons after an addon error
1 parent d544573 commit c8596bc

File tree

4 files changed

+32
-11
lines changed

4 files changed

+32
-11
lines changed

src/client/collections/addons.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ define([
33
"underscore",
44
"hr/hr",
55
"core/backends/rpc",
6-
"models/addon"
7-
], function(Q, _, hr, rpc, Addon) {
6+
"models/addon",
7+
"utils/dialogs"
8+
], function(Q, _, hr, rpc, Addon, dialogs) {
89
var Addons = hr.Collection.extend({
910
model: Addon,
1011
defaults: _.defaults({
@@ -172,10 +173,16 @@ define([
172173
return addon.load({}, _.pick(that.provides, addon.get("client.consumes", []))).fail(function(err) {
173174
err.addon = addon;
174175
return Q.reject(err);
176+
}).then(function(provides) {
177+
_.extend(that.provides, provides || {});
178+
}, function(err) {
179+
return dialogs.alert("Error with addon '"+addon.get("name")+"'", "<p>Error when initializing this addon. Please check addons states using the addons manager and reinstall this addon.</p><p>Error message:"+ (err.message || err) +"</p>");
180+
}).then(function() {
181+
return Q();
182+
}, function() {
183+
return Q();
175184
});
176-
}).then(function(provides) {
177-
_.extend(that.provides, provides || {});
178-
});
185+
})
179186
}, Q({}));
180187
}
181188
});

src/client/core/app.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ box, session, addons, box, files, commands, menu, tabs, panels, operations, loca
118118
operations.render();
119119

120120
// Load addons
121-
addons.loadAll().fail(function(err) {
122-
dialogs.alert("Warning!", "<p>Error when initializing addons, it's possible that one of the addons is not correctly loaded. Please check addons states using the addons manager.</p><p>Addon ref: "+err.addon.get("name")+"</p><p>Error message:"+ err.message+"</p>");
123-
}).fin(function() {
121+
addons.loadAll().fin(function() {
124122
// Remove loading state
125123
that.$(".cb-loading-alert").remove();
126124

src/client/core/localfs.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,17 @@ define([
333333
logger.log(" -> box:", boxFile.get("mtime"));
334334
logger.log(" -> local:", localEntry.mtime);*/
335335
return readFile(localEntry._fullPath).then(function(content) {
336-
return parent.write(content, localEntry._fullPath);
336+
return parent.read(localEntry._fullPath).then(function(vfsContent) {
337+
if (vfsContent == content) {
338+
// Same content
339+
return Q();
340+
}
341+
return dialogs.confirm("Upload modifications of "
342+
+localEntry._fullPath+" ("+vfsContent.length+"bytes to "+content.length+"bytes)");
343+
}).then(function(confirm) {
344+
if (!confirm) return;
345+
return parent.write(content, localEntry._fullPath);
346+
});
337347
});
338348
}
339349

src/client/models/file.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -379,15 +379,21 @@ define([
379379
/*
380380
* Download
381381
*/
382-
download: function(options) {
382+
download: function(filename, options) {
383383
var url, d, that = this;
384+
385+
if (_.isObject(filename)) {
386+
options = filename;
387+
filename = null;
388+
}
389+
384390
options = _.defaults(options || {}, {
385391
redirect: false
386392
});
387393
if (options.redirect) {
388394
window.open(this.exportUrl(),'_blank');
389395
} else {
390-
return this.vfsRequest("read", this.vfsUrl()).then(function(content) {
396+
return this.vfsRequest("read", this.vfsUrl(filename, false)).then(function(content) {
391397
that.setCache(content);
392398
that.modifiedState(false);
393399
return content;

0 commit comments

Comments
 (0)