mirror of https://codeberg.org/pzp/pzp-gc.git
refactor code
This commit is contained in:
parent
62c321a1b8
commit
b0cfedbb00
|
@ -4,3 +4,4 @@ pnpm-lock.yaml
|
|||
package-lock.json
|
||||
coverage
|
||||
*~
|
||||
lib/*.d.ts
|
||||
|
|
15
lib/index.js
15
lib/index.js
|
@ -130,8 +130,15 @@ function initGC(peer, config) {
|
|||
: kbRemaining > 0
|
||||
? `${kbRemaining}KB`
|
||||
: `${bytesRemaining}B`
|
||||
// prettier-ignore
|
||||
debug('Log is %s% full (only %s of free space), needs cleanup', percentUsed.toFixed(0), remaining)
|
||||
if (bytesRemaining > 0) {
|
||||
// prettier-ignore
|
||||
debug('Log is %s% full (only %s of free space), needs cleanup', percentUsed.toFixed(0), remaining)
|
||||
} else if (bytesRemaining === 0) {
|
||||
debug('Log is full, needs cleanup')
|
||||
} else {
|
||||
// prettier-ignore
|
||||
debug('Log is %s% full (%s beyond limit), needs cleanup', percentUsed.toFixed(0), remaining.slice(1))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -160,8 +167,8 @@ function initGC(peer, config) {
|
|||
function monitorLogSize(maxLogBytes) {
|
||||
assertDBPlugin(peer)
|
||||
|
||||
/** Number of records that match roughly 1% of the max log size */
|
||||
const CHECKPOINT = Math.floor((maxLogBytes * 0.01) / 500) // assuming 1 record = 500 bytes
|
||||
/** Number of records that match roughly 1% of the max log size */
|
||||
const CHECKPOINT = Math.floor((maxLogBytes * 0.01) / 500) // assuming 1 record = 500 bytes
|
||||
|
||||
function checkLogSize() {
|
||||
assertDBPlugin(peer)
|
||||
|
|
11
package.json
11
package.json
|
@ -11,8 +11,7 @@
|
|||
},
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
"*.js",
|
||||
"lib/*.js"
|
||||
"lib/**"
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
|
@ -42,10 +41,14 @@
|
|||
"rimraf": "^4.4.0",
|
||||
"secret-handshake-ext": "^0.0.8",
|
||||
"secret-stack": "~7.1.0",
|
||||
"ssb-box": "^1.0.1"
|
||||
"ssb-box": "^1.0.1",
|
||||
"typescript": "^5.1.3"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node --test",
|
||||
"clean-check": "tsc --build --clean",
|
||||
"prepublishOnly": "npm run clean-check && tsc --build",
|
||||
"postpublish": "npm run clean-check",
|
||||
"test": "npm run clean-check && node --test",
|
||||
"format-code": "prettier --write \"(lib|test)/**/*.js\"",
|
||||
"format-code-staged": "pretty-quick --staged --pattern \"(lib|test)/**/*.js\"",
|
||||
"coverage": "c8 --reporter=lcov npm run test"
|
||||
|
|
Loading…
Reference in New Issue