Skip to content

Commit fb71b55

Browse files
Merge pull request #49 from undefined-hestudio/main
### 1.4.6 1. external.refreshtask: Fix the problem of code structure update causing large-scale error reporting of scheduled tasks.
2 parents 346fd6f + 05f52f8 commit fb71b55

File tree

4 files changed

+25
-30
lines changed

4 files changed

+25
-30
lines changed

CHANGELOG

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### 1.4.6
2+
1. external.refreshtask: Fix the problem of code structure update causing large-scale error reporting of scheduled tasks.
3+
14
### 1.4.5
25
1. external.refreshtask: Fix an issue where scheduled tasks have stopped running even though they haven't finished running yet.
36
2. server.getupdate: Optimize the error-throwing mechanism when checking for updates.

get.js

+21-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require("dotenv").config();
2-
const VERSION = "1.4.5";
2+
const VERSION = "1.4.6";
33

44
const express = require("express");
55
const schedule = require("node-schedule");
@@ -185,15 +185,6 @@ if (
185185
}
186186

187187
function cacheimg() {
188-
if (typeof hbwgConfig.refreshtask === "function") {
189-
try {
190-
logwarn("task is running...");
191-
hbwgConfig.refreshtask();
192-
logwarn("task is finish.");
193-
} catch (e) {
194-
logerr(`refreshtask: ${e}`);
195-
}
196-
}
197188
if (hbwgConfig.getupdate !== false) {
198189
const requestOptions = {
199190
method: "GET",
@@ -206,22 +197,22 @@ function cacheimg() {
206197
}
207198
fetch(hbwgConfig.packageurl, requestOptions)
208199
.then((response) => response.json())
209-
.then((result) => AfterGetVersion(result))
200+
.then(async (result) => await AfterGetVersion(result))
210201
.catch((error) => logerr(`getupdate: ${error}`));
211202
}
212203
fetch(hbwgConfig.api, {
213204
method: "GET",
214205
redirect: "follow",
215206
})
216207
.then((response) => response.json())
217-
.then((result) => {
208+
.then(async (result) => {
218209
hbwgConfig.bingsrc = result;
219210
const url = hbwgConfig.host + result.images[0].url;
220-
fetch(url, {
211+
await fetch(url, {
221212
method: "GET",
222213
})
223-
.then((response) => {
224-
response.arrayBuffer().then(async (buffer) => {
214+
.then(async (response) => {
215+
await response.arrayBuffer().then(async (buffer) => {
225216
await (hbwgConfig.image = Buffer.from(buffer));
226217
});
227218
})
@@ -230,8 +221,21 @@ function cacheimg() {
230221
hbwgConfig.copyrightlink = String(result.images[0].copyrightlink);
231222
hbwgConfig.title = String(result.images[0].title);
232223
})
233-
.catch((error) => logerr(`source.bingsrc: ${error}`));
234-
224+
.catch((error) => {
225+
logerr(`source.bingsrc: ${error}`);
226+
if (hbwgConfig.image == undefined) {
227+
process.exit(1);
228+
}
229+
});
230+
if (typeof hbwgConfig.refreshtask === "function") {
231+
try {
232+
logwarn("task is running...");
233+
hbwgConfig.refreshtask();
234+
logwarn("task is finish.");
235+
} catch (e) {
236+
logerr(`refreshtask: ${e}`);
237+
}
238+
}
235239
logback("Refresh Successfully!");
236240
}
237241

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hestudio-bingwallpaper-get",
3-
"version": "1.4.5",
3+
"version": "1.4.6",
44
"description": "A Bing wallpaper API interface that can directly image output images.",
55
"main": "get.js",
66
"scripts": {

releaseit

-12
This file was deleted.

0 commit comments

Comments
 (0)