Coder Social home page Coder Social logo

diskspace.js's People

Contributors

ganna-shmatova avatar jimmywarting avatar keverw avatar kingsamchen avatar kornelski avatar patrickcosmo avatar svlapin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

diskspace.js's Issues

problem with path with spaces on windows

should change code to:

var exec = path.join(__dirname, 'drivespace.exe');
exec = '"' + exec + '" drive-' + drive;

child_process.exec(exec, function(error, stdout, stderr)

Upgrading from 0.1.5 to 0.1.7 broke my code

I upgraded to v0.1.7 and my code broke. I checked and realised that the first parameter of the callback function is now an error

before

var diskspace = require('diskspace');

diskspace.check('/', function(total, free) {
  fn(bytes(total), bytes(free));
});

after

var diskspace = require('diskspace');

diskspace.check('/', function(err, total, free) {
  if (err) return fn(err);
  fn(bytes(total), bytes(free));
});

You should consider using http://semver.org/

TOTAL = FREE = 0 since @1.0.0 (Mac OS X - El Capitan)

The version @1.0.0 doesn't work for me on Mac OS X - El Capitan (10.11.1) because of this code :

if(disk_info[5] != drive.replace(/'/g,"'\\''")){ //if not mount point
    free = total = 0;
}

In fact, the df -k command gives me something like :

Filesystem    1024-blocks      Used Available Capacity   iused   ifree %iused  Mounted on
/dev/disk1      487350400 457065864  30028536    94% 114330464 7507134   94%   /

And then freeand totalvars are always equal to 0.

Cannot launch Driveshare gui

Hello,
I am trying to launch the Driveshare gui with npm start after installing the node package. However, nothing comes up. No errors or anything. What could be wrong?

Enhancement request

Would it be possible to add in an option to toggle human readable disk info for Linux (df -h) vs. just returning the df -k info?

So you would pass in both the disk to look at, as well as the format the output would take.

Error on Windows when the App Directory contains a space, like "Program Files"

Hello,

I noticed that on windows, when the script try to launch diskspace.exe, there's an error when the full path contains a space such as : "C:\Program Files (x86)"

Output :
C:\Windows\system32\cmd.exe /s /c "C:\Program Files (x86)\APP_NAME\resources\app\node_modules\diskspace\drivespace.exe drive-C"

'C:\Program' n'est pas reconnu en tant que commande interne (french for Command not found)

Error: Command failed: df -k '/data' on Ubuntu Azure VM

Hello!

I use Diskspace npm package (version 2.0.0) in my node.js project and I have 3 different environments: Windows 10 on developer's computer, Debian 8 on staging environment and production on Ubuntu 14.04.5 LTS on Azure VM. When I use it on dev or staging envs, all is ok, and it correct works on production with root disk ("/"), but when I have added one more disk ("/data" mountpoint, for example), I have this error:

Problem with command Error:
Command failed: df -k '/data'df: '/data':
No such file or directory
Error: Command failed: df -k '/data',df: '/data':
No such file or directory,,
at ChildProcess.exithandler (child_process.js:204:12),
at emitTwo (events.js:106:13),
at ChildProcess.emit (events.js:191:7),
at maybeClose (internal/child_process.js:886:16),
at Socket. (internal/child_process.js:342:11),
at emitOne (events.js:96:13),
at Socket.emit (events.js:188:7),
at Pipe._handle.close [as _onclose] (net.js:501:12)

Of course, volume '/data' exists and correct works. Command "df -k '/data' " also correct works in terminal.

Any help will be appreciated

Doesn't work on CentOS + Solution

This module uses the df -k command to get the disk usage info. Problem is that the output for df -k is slightly different on CentOS than on other linux distributions.

On CentOS, for example, "df -k /" can output this:

Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup-lv_root
51606140 5131448 43853252 11% /

Notice there are 3 lines in the output above. On debian squeeze and other linux distributions the output is only two lines, like this:

Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 7867856 1768364 5699828 24% /

The problem is that the code always looks for the data on the second line of output. The safer thing to do is to look at the last line of output.

The FIX is to change these two lines:

var lines = stdout.split("\n");
var str_disk_info = lines[1].replace( /[\s\n\r]+/g,' ');

to this:

var lines = stdout.trim().split("\n");
var str_disk_info = lines[lines.length - 1].replace( /[\s\n\r]+/g,' ');

I'm not sure how to commit this change to github, or if I'm even allowed (have access) to do this.

Add type information

For function check should be JSDoc information added with input parameters types and output callback results

Not working at Ubuntu Core 18 over Raspberry PI 3 Model B

First, thanks and congrats for this work!

I am trying to get disk stats of a system Ubuntu Core 18 running over Raspberry PI 3 Model B with a MicroSD disk. The df -h of system is:

image

I test passing "/" and "/writable" to lib, but it do not get free space correctly:

{"total":50200576,"used":50200576,"free":0,"status":"READY"} (to "/writable").

Any tip to fix?

Also return "Used" diskspace from `df -k`

Hello,

Currently, diskspace returns the Total and Available disk space. One would think that we can guess the Used diskspace by doing: Total - Available. However, this is not accurate, probably for the following reason: https://askubuntu.com/questions/249387/df-h-used-space-avail-free-space-is-less-than-the-total-size-of-home#249415

Example:

$ df -k .
Filesystem 1024-blocks      Used Available Capacity  iused    ifree %iused  Mounted on
/dev/disk1   243924992 117961984 125707008    49% 29554494 31426752   48%   /
  • Used = 117961984
  • Total - Available = 118217984

Would that be good idea to also return the Used diskspace?

Thanks

the EXE file crashed on windows server 2008 r2 enterprise sp1

I'm sorry I comment this without reading readme file, now I write the drivespace.exe with cpp, it can work without .net.

#include <windows.h>
#include <tchar.h>
#include <stdio.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
char* ptr = lpCmdLine;
while (*ptr != 0x0)
{
if (islower(*ptr))
{
*ptr = toupper(*ptr);
}
ptr++;
}
char *p, *safePtr;
p = strtok_s(lpCmdLine, "-", &safePtr);
if (!p || strcmp(p,"DRIVE") || !safePtr || strlen(safePtr)<=0)
{
printf("0,0,NOTFOUND");
return -1;
}
char disk[] = "C:";
disk[0] = *safePtr;
DWORD64 qwFreeBytes=0, qwFreeBytesToCaller=0, qwTotalBytes=0;
BOOL bResult = GetDiskFreeSpaceEx(disk,
(PULARGE_INTEGER)&qwFreeBytesToCaller,
(PULARGE_INTEGER)&qwTotalBytes,
(PULARGE_INTEGER)&qwFreeBytes);
if (!bResult)
{
printf("0,0,NOTFOUND");
return -1;
}

printf("%lld,%lld,READY",qwTotalBytes,qwFreeBytes);
return 0;

}

Sync call support?

What's the easiest way to make this into a method that is synchronous? The callback doesn't contain the error first, so I can't apply normal async call patterns to it to make it sync.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.