Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Return promises
Browse files Browse the repository at this point in the history
  • Loading branch information
claviska committed May 23, 2017
1 parent 895dfc4 commit 876c264
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions source/controllers/api/backup_controller.js
Expand Up @@ -74,17 +74,14 @@ function restoreData(model, zip) {

if(data && data.length) {
// Empty the table
model.destroy({ truncate: true })
return model.destroy({ truncate: true })
.then(() => {
// Restore all rows
data.forEach((row) => queue.push(model.create(row)));

// Wait for all rows to populate before proceeding
Promise.all(queue)
.then(() => resolve(zip))
.catch((err) => reject(err));
})
.catch((err) => reject(err));
return Promise.all(queue).then(() => resolve(zip));
});
} else {
return resolve(zip);
}
Expand Down Expand Up @@ -151,10 +148,7 @@ function restoreFolderFromZip(sourceFolder, targetFolder, zip) {
});

// Wait for all files to be written before proceeding
Promise.all(queue)
.then(() => resolve(zip))
.catch((err) => reject(err));

return Promise.all(queue).then(() => resolve(zip));
} else {
// No files, continue restoring
resolve(zip);
Expand Down

0 comments on commit 876c264

Please sign in to comment.