From d4f78e080064746ba0ec00361d541db7942963ae Mon Sep 17 00:00:00 2001 From: Cassie Tarakajian Date: Wed, 27 Dec 2017 12:19:53 -0500 Subject: [PATCH] another fix --- server/migrations/moveBucket.js | 37 +++++++++++++++++---------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/server/migrations/moveBucket.js b/server/migrations/moveBucket.js index ebf03a5c..b70d3ef9 100644 --- a/server/migrations/moveBucket.js +++ b/server/migrations/moveBucket.js @@ -35,25 +35,26 @@ Project.count({}) return index < numProjects; }, (whilstCb) => { - let projects = await Project.find({}).skip(index).limit(CHUNK).exec(); - async.eachSeries(projects, (project, cb) => { - console.log(project.name); - async.eachSeries(project.files, (file, fileCb) => { - if (file.url && file.url.includes('p5.js-webeditor')) { - file.url = file.url.replace('p5.js-webeditor', process.env.S3_BUCKET); - project.save((err, newProject) => { - console.log(`updated file ${file.url}`); - process.exit(0); + Project.find({}).skip(index).limit(CHUNK).exec((err, projects) => { + async.eachSeries(projects, (project, cb) => { + console.log(project.name); + async.eachSeries(project.files, (file, fileCb) => { + if (file.url && file.url.includes('p5.js-webeditor')) { + file.url = file.url.replace('p5.js-webeditor', process.env.S3_BUCKET); + project.save((err, newProject) => { + console.log(`updated file ${file.url}`); + process.exit(0); + fileCb(); + }); + } else { fileCb(); - }); - } else { - fileCb(); - } - }, () => { - cb(); - }, () => { - index += CHUNK; - whilstCb(); + } + }, () => { + cb(); + }, () => { + index += CHUNK; + whilstCb(); + }); }); }); },