Skip to content

Commit 9955df3

Browse files
authored
Fix sync size max (OpenUserJS#1716)
Closes OpenUserJS#1715 Auto-merge
1 parent 199d8c9 commit 9955df3

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

libs/repoManager.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ var Strategy = require('../models/strategy').Strategy;
1414

1515
var nil = require('./helpers').nil;
1616
var github = require('../libs/githubClient');
17+
var settings = require('../models/settings.json');
18+
1719

1820
var clientId = null;
1921
var clientKey = null;
@@ -121,12 +123,16 @@ RepoManager.prototype.loadScripts = function (aUpdate, aCallback) {
121123
var url = '/' + encodeURI(aRepo.user) + '/' + encodeURI(aRepo.repo)
122124
+ '/master' + aScript.path;
123125
fetchRaw('raw.githubusercontent.com', url, function (aBufs) {
124-
scriptStorage.getMeta(aBufs, function (aMeta) {
125-
if (aMeta) {
126-
scriptStorage.storeScript(that.user, aMeta, Buffer.concat(aBufs), aUpdate,
127-
aInnerCallback);
128-
}
129-
});
126+
var thisBuf = Buffer.concat(aBufs);
127+
128+
if (thisBuf.byteLength <= settings.maximum_upload_script_size) {
129+
scriptStorage.getMeta(aBufs, function (aMeta) {
130+
if (aMeta) {
131+
scriptStorage.storeScript(that.user, aMeta, thisBuf, aUpdate,
132+
aInnerCallback);
133+
}
134+
});
135+
}
130136
});
131137
}, aCallback);
132138
});

0 commit comments

Comments
 (0)