bugfixes and improvements

This commit is contained in:
orangecoding
2026-06-13 14:02:42 +02:00
parent 94384df36d
commit 9207280ab4
12 changed files with 32 additions and 21 deletions

View File

@@ -17,16 +17,16 @@ const userAgents = [
];
/**
* Check if a listing is still active with up to 5 attempts and exponential backoff.
* Check if a listing is still active with up to `maxAttempts` attempts and exponential backoff.
* Backoff waits are randomized and capped.
*
* Rules:
* - HTTP 200 => return 1 (if checkForText is provided and found, returns 0)
* - HTTP 401/403 => return -1 (most certainly detected as a bot)
* - HTTP 404 => return 0
* - HTTP 404/410 => return 0
* - Other statuses or network errors => retry until attempts are exhausted
*
* @returns {Promise<Integer>} 1 if active, 0 if not active and -1 if detected as bot
* @returns {Promise<number>} 1 if active, 0 if not active and -1 if detected as bot
*/
export default async function checkIfListingIsActive(link, checkForText = null) {
await sleep(randomBetween(50, 100));

View File

@@ -40,7 +40,8 @@ class SqliteConnection {
}
/**
* Returns a singleton instance of better-sqlite3 Database.
* Respects env var SQLITE_DB_PATH and defaults to db/listings.db.
* Uses the configured `sqlitepath` (from conf/config.json) as the directory,
* defaulting to `/db` (relative to the project root) when unset.
*/
static getConnection() {
if (this.#db) return this.#db;