From 9955df394662c8c6b0798e8fa71b00c58c983d94 Mon Sep 17 00:00:00 2001 From: Marti Martz Date: Sun, 12 Apr 2020 15:32:24 -0600 Subject: [PATCH] Fix sync size max (#1716) Closes #1715 Auto-merge --- libs/repoManager.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/libs/repoManager.js b/libs/repoManager.js index a94bea310..2b9d0df3c 100644 --- a/libs/repoManager.js +++ b/libs/repoManager.js @@ -14,6 +14,8 @@ var Strategy = require('../models/strategy').Strategy; var nil = require('./helpers').nil; var github = require('../libs/githubClient'); +var settings = require('../models/settings.json'); + var clientId = null; var clientKey = null; @@ -121,12 +123,16 @@ RepoManager.prototype.loadScripts = function (aUpdate, aCallback) { var url = '/' + encodeURI(aRepo.user) + '/' + encodeURI(aRepo.repo) + '/master' + aScript.path; fetchRaw('raw.githubusercontent.com', url, function (aBufs) { - scriptStorage.getMeta(aBufs, function (aMeta) { - if (aMeta) { - scriptStorage.storeScript(that.user, aMeta, Buffer.concat(aBufs), aUpdate, - aInnerCallback); - } - }); + var thisBuf = Buffer.concat(aBufs); + + if (thisBuf.byteLength <= settings.maximum_upload_script_size) { + scriptStorage.getMeta(aBufs, function (aMeta) { + if (aMeta) { + scriptStorage.storeScript(that.user, aMeta, thisBuf, aUpdate, + aInnerCallback); + } + }); + } }); }, aCallback); });