Skip to content
This repository was archived by the owner on Jun 27, 2019. It is now read-only.

Commit 1fe6089

Browse files
fixing image save hook
1 parent ff7714d commit 1fe6089

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

server/hooks/save-remote-images.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ module.exports = function (options = []) { // eslint-disable-line no-unused-vars
9797
try {
9898
const mimeType = res.headers['content-type'];
9999
if (mimeType.indexOf('image') !== 0) {
100-
// hook.app.log('~~~~~its not an image');
101-
reject('its not an image');
100+
hook.app.error('its not an image');
101+
reject(new Error('its not an image'));
102102
}
103103

104104
const ext = mime.getExtension(mimeType);
@@ -116,9 +116,12 @@ module.exports = function (options = []) { // eslint-disable-line no-unused-vars
116116
if (imgCount > 0 && loading <= 0) {
117117
hook.app.debug('Download(s) finished', urls);
118118
resolve(hook);
119+
} else if (!imgCount) {
120+
resolve(hook);
119121
}
120122
} catch (err) {
121123
hook.app.error(err);
124+
reject(err);
122125
}
123126
});
124127
} else {
@@ -131,7 +134,7 @@ module.exports = function (options = []) { // eslint-disable-line no-unused-vars
131134
if (imgCount > 0 && loading <= 0) {
132135
hook.app.debug('Download(s) finished', urls);
133136
resolve(hook);
134-
} else if (imgCount <= 0) {
137+
} else if (!imgCount) {
135138
resolve(hook);
136139
}
137140
} catch (err) {

0 commit comments

Comments
 (0)