Allowing image sources to specify queue method. Using 5s queue for Whale Member to avoid CDN time-outs.
This commit is contained in:
@@ -89,6 +89,8 @@ function toBaseSource(rawSource) {
|
||||
|
||||
if (rawSource.referer) baseSource.referer = rawSource.referer;
|
||||
if (rawSource.host) baseSource.host = rawSource.host;
|
||||
if (rawSource.attempts) baseSource.attempts = rawSource.attempts;
|
||||
if (rawSource.queueMethod) baseSource.queueMethod = rawSource.queueMethod;
|
||||
|
||||
if (rawSource.copyright) baseSource.copyright = rawSource.copyright;
|
||||
if (rawSource.comment) baseSource.comment = rawSource.comment;
|
||||
@@ -393,6 +395,7 @@ async function fetchSource(source, baseMedia) {
|
||||
stream: true, // sources are fetched in parallel, don't gobble up memory
|
||||
transforms: [hashStream],
|
||||
destination: tempFileTarget,
|
||||
queueMethod: source.queueMethod || null, // use http module's default
|
||||
});
|
||||
|
||||
hasher.end();
|
||||
@@ -422,9 +425,11 @@ async function fetchSource(source, baseMedia) {
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
logger.warn(`Failed attempt ${attempts}/3 to fetch ${source.src}: ${error.message}`);
|
||||
const maxAttempts = source.attempts || 3;
|
||||
|
||||
if (attempts < 3) {
|
||||
logger.warn(`Failed attempt ${attempts}/${maxAttempts} to fetch ${source.src}: ${error.message}`);
|
||||
|
||||
if (attempts < maxAttempts) {
|
||||
await Promise.delay(1000);
|
||||
|
||||
return attempt(attempts + 1);
|
||||
|
||||
Reference in New Issue
Block a user