Skip to content

Add fs.statvfs function to get disk size/free/available space + other info #10745

Description

@miniak

There is no build in way to get disk space information. There are a few npm modules available:

This is such a basic API that should be built-in.

Activity

  1. added
    feature requestIssues requesting new Node.js features.
    fsIssues and PRs related to file-system APIs and the fs module.
    on Jan 11, 2017
  2. mscdex commented on Jan 11, 2017

    @mscdex
    Contributor

    libuv would need to add such support first, then node would add an API that uses that libuv API.

  3. added
    libuvIssues and PRs related to the libuv dependency or the uv binding.
    on Jan 11, 2017
  4. cjihrig commented on Jan 12, 2017

    @cjihrig
    Contributor

    From what I can tell, the modules you linked to only provide a subset of what statvfs(). libuv would also require a Windows implementation. It looks like Python rejected a Windows implementation a while back (not sure if that has since changed).

    cc: @saghul

  5. ronkorving commented on Jan 12, 2017

    @ronkorving
    Contributor

    @miniak I use https://www.npmjs.com/package/storage-device-info, which only depends on NAN. Regardless though, it would be nice to have this built-in.

  6. saghul commented on Jan 13, 2017

    @saghul
    Member
  7. Trott commented on Jul 15, 2017

    @Trott
    Member

    Given that this issue has been inactive for several months, is it sensible close this (or at least mark is at blocked) unless and until the necessary features are added to libuv?

  8. ronkorving commented on Jul 15, 2017

    @ronkorving
    Contributor

    I think this is still valid, regardless of people having have spent time on it.

  9. added
    blockedPRs that are blocked by other issues or PRs.
    on Jul 16, 2017
  10. added
    help wantedIssues that need assistance from volunteers or PRs that need help to proceed.
    on Jul 17, 2017
  11. gengjiawen commented on Mar 5, 2018

    @gengjiawen
    Member

    https://github.com/jduncanator/node-diskusage now implements in C++, it also have a Windows implementation.

  12. refack commented on Nov 11, 2018

    @refack
    Contributor
  13. tomasdev commented on Mar 9, 2019

    @tomasdev

    So is this happening or not? I see it on the project dashboard but it's now closed?

  14. 10 remaining items

  15. added 2 commits that reference this issue on Jan 14, 2020
  16. added a commit that references this issue on Feb 11, 2020
  17. nahuel commented on Sep 28, 2020

    @nahuel

    please reopen this issue, is not resolved yet.

  18. EagleLizard commented on Dec 18, 2021

    @EagleLizard

    Is there any ETA for this? Stats does not show the size on disk, which is an issue because it reports file sizes of <20B on disks, when the actual minimum block size for files on a given disk may be ~4096B, so disk calcs end up with significant mismatches

  19. added a commit that references this issue on Jan 29, 2023
  20. added a commit that references this issue on Feb 1, 2023
  21. koplenov commented on Aug 26, 2024

    @koplenov
  22. koplenov commented on Aug 26, 2024

    @koplenov

    For example, let's find out the free disk space as a percentage:

    /*
    	https://nodejs.org/api/fs.html#fspromisesstatfspath-options
    */
    
    const fsp = require("node:fs/promises");
    
    (async function (){
    	const { bfree, blocks } = await fsp.statfs(__dirname)
    	const persent = bfree/blocks*100
    	console.log({persent})
    })()
  23. avivkeller commented on Aug 26, 2024

    @avivkeller
    Member

    This issue can been closed for years. If you're experiencing an issue, please open a new issue in nodejs/help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    blockedPRs that are blocked by other issues or PRs.feature requestIssues requesting new Node.js features.fsIssues and PRs related to file-system APIs and the fs module.help wantedIssues that need assistance from volunteers or PRs that need help to proceed.libuvIssues and PRs related to the libuv dependency or the uv binding.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions