Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var respShare = {
path: config.get(key + '.path'),
ip: config.get(key + '.ip'),
name: config.get(key + '.name'),
fstype: config.get(key + '.fstype'),
username: config.get(key + '.user'),
password: config.get(key + '.password'),
options: config.get(key + '.options'),
id: share,
mounted: mounted.mounted,
size: ''
};
var quotedmount = quotePath(mountpoint);
// cmd returns size in bytes with no units and no header line
var cmd="df -B1 --output=used " + quotedmount + " | tail -1";
var promise = libQ.ncall(exec,respShare,cmd).then(function (stdout){
var splitted=stdout.split('\n');
var sizeStr=splitted[0];
var size=parseInt(sizeStr) / 1024 / 1024;
var unity = 'MB';
if (size > 1024) {
size = size / 1024;
unity = 'GB';
if (size > 1024) {
size = size / 1024;
unity = 'TB';
}
}
respShare.size = size.toFixed(2) + " " + unity ;