mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
bugfixes and improvements
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user