mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-17 05:37:46 +00:00
尝试解决图片第一次下载失败后无法自动解决图片裂开问题&驱动盘序号错位问题
This commit is contained in:
parent
8304b8bffa
commit
839ca76855
6 changed files with 153 additions and 56 deletions
|
|
@ -1,6 +1,5 @@
|
|||
import http from 'http';
|
||||
import https from 'https';
|
||||
import fetch from 'node-fetch';
|
||||
export async function checkLatency(url) {
|
||||
let request = http;
|
||||
if (url.startsWith('https')) {
|
||||
|
|
@ -36,20 +35,3 @@ export function getQueryVariable(url, variable) {
|
|||
const key = searchParams.get(variable);
|
||||
return key;
|
||||
}
|
||||
|
||||
export async function fetchWithRetry(url, options, retry = 3) {
|
||||
let err;
|
||||
const _fetch = async (url, options, retryCount = 0) => {
|
||||
if (retryCount > retry) {
|
||||
throw new Error('Retry limit reached', err);
|
||||
}
|
||||
try {
|
||||
return await fetch(url, options);
|
||||
} catch (error) {
|
||||
logger.debug(`Fetch error: ${error.message}`);
|
||||
err = error;
|
||||
return _fetch(url, options, retryCount + 1);
|
||||
}
|
||||
};
|
||||
return _fetch(url, options);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue