{"id":19896805,"url":"https://github.com/achou11/ssb-storage-used","last_synced_at":"2025-05-02T20:31:08.178Z","repository":{"id":41566610,"uuid":"504572607","full_name":"achou11/ssb-storage-used","owner":"achou11","description":"secret stack plugin for getting storage usage information","archived":false,"fork":false,"pushed_at":"2023-01-30T16:02:30.000Z","size":211,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-17T01:25:35.351Z","etag":null,"topics":["secret-stack","ssb","ssb-db2"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/achou11.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-17T14:51:16.000Z","updated_at":"2023-08-05T22:39:30.000Z","dependencies_parsed_at":"2023-02-16T09:00:47.751Z","dependency_job_id":null,"html_url":"https://github.com/achou11/ssb-storage-used","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/achou11%2Fssb-storage-used","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/achou11%2Fssb-storage-used/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/achou11%2Fssb-storage-used/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/achou11%2Fssb-storage-used/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/achou11","download_url":"https://codeload.github.com/achou11/ssb-storage-used/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252104126,"owners_count":21695420,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["secret-stack","ssb","ssb-db2"],"created_at":"2024-11-12T18:40:35.989Z","updated_at":"2025-05-02T20:31:07.860Z","avatar_url":"https://github.com/achou11.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ssb-storage-used\n\n\u003e secret stack plugin for getting storage usage information\n\n\n## Install\n\n`npm install ssb-storage-used`\n\n## Usage\n\n* Requires **Node 12** or higher\n* Requires `ssb-db2`\n\n```diff\nSecretStack({appKey: require('ssb-caps').shs})\n+ .use(require('ssb-db2'))\n+ .use(require('ssb-storage-used'))\n  .call(null, config)\n```\n\n## API\n\n### `ssb.storageUsed.getBytesStored(feedId, cb) (muxrpc \"async\")`\n\n- `feedId`: the feed id to get the bytes stored for\n- `cb`: callback(err, bytesStored) where `bytesStored` is a number\n\nGets the total number of bytes stored on disk for a provided `feedId`\n\n```js\nssb.storageUsed.getBytesStored(ssb.id, (err, bytesStored) =\u003e {\n  console.log(`Feed ${ssb.id} uses ${bytesStored} bytes`)\n})\n```\n\n### `ssb.storageUsed.stats(cb) (muxrpc \"async\")`\n\n- `cb`: callback(err, stats)\n  - `stats` is an object with the following fields:\n    - `blobs: number`\n    - `indexes: number`\n    - `jitIndexes: number`\n    - `log: number`\n    - `logUsedBytes: number`\n    - `logDeletedBytes: number`\n  - `err` will return the **first** error that occurs when checking the various directories\n\nGet information about how much disk space `ssb/db2` takes up. This includes the log file, the indexes directories, and the blobs directories. Additionally, `logUsedBytes` and `logDeletedBytes` are statistics about the internals of the log file, and come from [async-append-only-log](https://github.com/ssbc/async-append-only-log)'s `stats` method.\n\n```js\nssb.storageUsed.stats((err, stats) =\u003e {\n  Object.entries(stats).forEach(([name, bytesStored]) =\u003e {\n    console.log(`${name} takes up ${bytesStored} bytes`)\n  })\n})\n```\n\n### `ssb.storageUsed.stream(): PullStream\u003c[feedId, bytes]\u003e (muxrpc \"source\")`\n\nGet a pull stream that sends a tuple where the first item is the feed id and the second item is the number of bytes used by that feed. The items returned by the stream are sorted from the highest to lowest `bytes` values.\n\n```js\npull(\n  ssb.storageUsed.stream(),\n  pull.map((item) =\u003e {\n    const [feedId, bytes] = item\n    console.log(`Feed ${feedId} uses ${bytes} bytes`)\n  })\n)\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fachou11%2Fssb-storage-used","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fachou11%2Fssb-storage-used","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fachou11%2Fssb-storage-used/lists"}