mirror of
https://github.com/GenderDysphoria/GenderDysphoria.fyi.git
synced 2025-01-31 07:16:17 +00:00
Fallback to local duplicate when a fetch fails, if available
This commit is contained in:
parent
b027c43a18
commit
b5851b4c38
@ -4,6 +4,7 @@ const log = require('fancy-log');
|
|||||||
const Promise = require('bluebird');
|
const Promise = require('bluebird');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const actions = require('./actions');
|
||||||
|
|
||||||
const LOG = {
|
const LOG = {
|
||||||
new: true,
|
new: true,
|
||||||
@ -45,8 +46,21 @@ module.exports = exports = async function process (tasks, cache) {
|
|||||||
output: 'dist/' + output,
|
output: 'dist/' + output,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
log.error(`Task (${task.action.name}) failed for file ${output}.\n`, err);
|
if (status.duplicate && await fs.pathExists(status.duplicate)) {
|
||||||
return false;
|
try {
|
||||||
|
result = await actions.copy({
|
||||||
|
input: status.duplicate,
|
||||||
|
output: 'dist/' + output,
|
||||||
|
});
|
||||||
|
log.info(`Task (${task.action.name}) failed for file ${output}, fell back to saved duplicate ${status.duplicate}`);
|
||||||
|
} catch (err2) {
|
||||||
|
log.error(`Task (${task.action.name}) failed for file ${output}.\n`, err);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.error(`Task (${task.action.name}) failed for file ${output}.\n`, err);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
status = await cache.set(task, result, lastSeen);
|
status = await cache.set(task, result, lastSeen);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user