Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
use async version of diskpace check to prevent EMFILE
Browse files Browse the repository at this point in the history
  • Loading branch information
Gordon Hall committed Aug 9, 2016
1 parent 75f5226 commit 53802bd
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions app/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var about = require('./package');
var Updater = require('./lib/updater');
var UserData = require('./lib/userdata');
var Tab = require('./lib/tab');
var diskspace = require('fd-diskspace').diskSpaceSync;
var diskspace = require('fd-diskspace').diskSpace;
var storj = require('storj');
var Monitor = storj.Monitor;
var SpeedTest = require('myspeed').Client;
Expand Down Expand Up @@ -521,20 +521,28 @@ var main = new Vue({

},
getFreeSpace: function(tab) {
var disks = diskspace().disks;
var free = 0;

for (var disk in disks) {
if (tab.storage.path.indexOf(disk) !== -1) {
// The `df` command on linux returns KB by default, so we need to
// convert to bytes.
free = process.platform === 'win32' ?
disks[disk].free :
disks[disk].free * 1000;
var self = this;

diskspace(function(err, result) {
if (err) {
return;
}
}
var freespace = utils.autoConvert({size: free, unit: 'B'});
this.freespace = freespace;

var free = 0;

for (var disk in result.disks) {
if (tab.storage.path.indexOf(disk) !== -1) {
// The `df` command on linux returns KB by default, so we need to
// convert to bytes.
free = process.platform === 'win32' ?
result.disks[disk].free :
result.disks[disk].free * 1000;
}
}

var freespace = utils.autoConvert({size: free, unit: 'B'});
self.freespace = freespace;
});
}
},
created: function() {
Expand Down

0 comments on commit 53802bd

Please sign in to comment.