mirror of https://codeberg.org/pzp/pzp-sync.git
Fix not checking null on dbtangle call
This commit is contained in:
parent
b851d3eaf1
commit
2b74aa6b1a
|
@ -10,6 +10,7 @@ const { EMPTY_RANGE, isEmptyRange, estimateMsgCount } = require('./range')
|
|||
* @typedef {ReturnType<import('pzp-dict').init>} PZPDict
|
||||
* @typedef {ReturnType<import('pzp-set').init>} PZPSet
|
||||
* @typedef {import('pzp-db/msg-v4').Msg} Msg
|
||||
* @typedef {import('pzp-db/db-tangle')} DBTangle
|
||||
* @typedef {import('pzp-goals').Goal} Goal
|
||||
* @typedef {import('./range').Range} Range
|
||||
* @typedef {string} MsgID
|
||||
|
@ -314,12 +315,15 @@ class Algorithm {
|
|||
* @param {number} count
|
||||
*/
|
||||
async pruneNewest(rootID, count) {
|
||||
/** @type {DBTangle | null} */
|
||||
const tangle = await p(this.#peer.db.getTangle)(rootID)
|
||||
if (!tangle) return
|
||||
const sorted = tangle.topoSort()
|
||||
if (sorted.length <= count) return
|
||||
const msgID = sorted[sorted.length - count] // New "oldest dataful msg"
|
||||
const { deletables, erasables } = tangle.getDeletablesAndErasables(msgID)
|
||||
const deletablesErasables = tangle.getDeletablesAndErasables(msgID)
|
||||
if (!deletablesErasables) return
|
||||
const { deletables, erasables } = deletablesErasables
|
||||
const del = p(this.#peer.db.del)
|
||||
const erase = p(this.#peer.db.erase)
|
||||
for (const msgID of deletables) {
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
"@types/node": "16.x",
|
||||
"c8": "7",
|
||||
"pzp-caps": "^1.0.0",
|
||||
"pzp-db": "^1.0.1",
|
||||
"pzp-db": "^1.0.4",
|
||||
"pzp-dict": "^1.0.0",
|
||||
"pzp-goals": "^1.0.0",
|
||||
"pzp-keypair": "^1.0.0",
|
||||
|
|
Loading…
Reference in New Issue