0

I am trying to get free disk space in an electron application targeting linux. I have following code to get free space.

const checkDiskSpace = require('check-disk-space').default
checkDiskSpace(path.dirname(__dirname)).then((diskSpace) => {
            console.log(diskSpace);
            successCallback(diskSpace.free);                 
}).catch(failCallback);

This one works for .deb but for AppImage and snap package it fails to execute this call. In AppImage, i get the following output.

diskPath: undefined
free: 0
size: 0

Any idea how can i make it work in these environments ?

Abdul
  • 77
  • 3
  • 9
  • That is correct for `__dirname` on snap, the packege is mounted onto it's own loop device. I assume Appimage is doing a similar thing. What is it your are trying to find the free space of? – Matt Jul 27 '22 at 02:07
  • I am downloading content from http and saving it on disk. Need to calculate disk space before persisting – Abdul Jul 27 '22 at 10:00
  • i do get **__dirname** resolved. ```/tmp/.mount_OmniverAjV1z/resources/app``` – Abdul Jul 27 '22 at 14:35
  • **Update** For AppImage i got it to work by replacing ```__dir``` with application dir. I guess loop device does not allow you to calculate size inside its structure. – Abdul Jul 27 '22 at 19:32

0 Answers0