re-use existing processed data

Do not save the error unless it occurs.
This commit is contained in:
buzz-lightsnack-2007 2024-05-05 14:40:03 +08:00
parent 87cac58d57
commit e72f37bff2

View file

@ -15,13 +15,23 @@ export default class processor {
} }
async analyze() { async analyze() {
this.product = new product(this.data); // Do not reset the product data, just re-use it.
this.product = (!this.product) ? new product(this.data) : this.product;
await this.product.attach(); await this.product.attach();
// Set up current data of the site, but forget about its previous errored state.
this.product.status[`done`] = false;
delete this.product.status[`error`];
// First save the SHA512 summary of the scraped data.
this.product.save();
// Try analysis of the data.
try { try {
await this.product.analyze(); await this.product.analyze();
} catch(err) { } catch(err) {
logging.error(err.name, err.message, err.stack, false); logging.error(err.name, err.message, err.stack, false);
this.product.status[`error`] = true; this.product.status[`error`] = err;
}; };
// Indicate that the process is done. // Indicate that the process is done.