From e72f37bff22195892996b5b6ac985eccaff57de9 Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Sun, 5 May 2024 14:40:03 +0800 Subject: [PATCH] re-use existing processed data Do not save the error unless it occurs. --- scripts/external/processor.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/external/processor.js b/scripts/external/processor.js index 526748b..4d86b06 100644 --- a/scripts/external/processor.js +++ b/scripts/external/processor.js @@ -15,13 +15,23 @@ export default class processor { } 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(); + + // 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 { await this.product.analyze(); } catch(err) { 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.