Skip to content

Commit

Permalink
fix: initializing db if db was closed
Browse files Browse the repository at this point in the history
  • Loading branch information
silkroadnomad committed Jan 22, 2025
1 parent 046fbdf commit ae73214
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
2 changes: 1 addition & 1 deletion relay/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "libp2p-relay",
"version": "0.12.54",
"version": "0.12.55",
"private": true,
"scripts": {
"start:no-restart": "node src/relay.js",
Expand Down
13 changes: 2 additions & 11 deletions relay/src/pinner/pinningService.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ export class PinningService {
* @returns {Promise<boolean>} - Should remain pinned
*/
async shouldRemainPinned(cid) {
if(!this.db) await this.initializeDatabase()
return this.queue.add(async () => {
const dbPath = './orbitdb/pinning-metadata';

// Clean up any stale lock files before opening
const MAX_RETRIES = 3;
Expand Down Expand Up @@ -283,16 +283,7 @@ export class PinningService {
}

await new Promise(resolve => setTimeout(resolve, RETRY_DELAY));
} finally {
if (this.db) {
try {
await this.db.close();
logger.info(`Database closed successfully after attempt ${attempt}`);
} catch (closeError) {
logger.error(`Error closing database on attempt ${attempt}:`, closeError);
}
}
}
}
}
});
}
Expand Down

0 comments on commit ae73214

Please sign in to comment.