sebhildebrandt / systeminformation

System Information Library for Node.JS
MIT License
2.65k stars 300 forks source link

Cant use fsSize in mas/mas-dev build - 'could not start up a diskmanagement session' #877

Closed Zedbyte-corp closed 6 months ago

Zedbyte-corp commented 6 months ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. used function 'fsSize()'
  2. code snippet
    ipcMain.on('check-storage', async (event, arg) => {
    console.log('fsSize', parse(arg.path).root)
    const parsedPath =
    process.platform === 'win32' ? parse(arg.path).root.slice(0, -1) : parse(arg.path).root
    await fsSize(parsedPath).then((data) => {
    console.log('fsSize', data, arg)
    for (var i = 0; i < data.length; i++) {
      if (data[i]['mount'].startsWith('/System')) {
        continue
      }
      if (data[i].available > arg.totalBytes) {
        event.sender.send('available-storage', true)
      } else {
        event.sender.send('available-storage', false)
      }
      break
    }
    })
    })
  3. start app / code
    window.electron.send('check-storage', {path: downloadPath.download_path, totalBytes: tempSize})
  4. See output/error 'could not start up a diskmanagement session'

Current Output 'could not start up a diskmanagement session'

Expected behavior Need to access fsSize() in production build with all the disk properties

Environment (please complete the following information):

To get all needed environment information, please run the following command:

  npx systeminformation info
sebhildebrandt commented 6 months ago

@Zedbyte-corp can you confirm, that the fsSize() function works outside of electron on your machine?

const si = require('systeminformation');
si.fsSize().then(data => console.log(data));

Does this produce meaningful output? If yes, I suppose that this is not a problem related to systeminformation

Zedbyte-corp commented 6 months ago

@Zedbyte-corp can you confirm, that the fsSize() function works outside of electron on your machine?

const si = require('systeminformation');
si.fsSize().then(data => console.log(data));

Does this produce meaningful output? If yes, I suppose that this is not a problem related to systeminformation

it produces correct output, but in electron production build it doesn't. Also im getting rw param as null for all drives in mas build.

Could not start up a DiskManagement session
drives [{"fs":"/dev/disk1s5s1","type":"HFS","size":250685575168,"used":10122358784,"available":23591677952,"use":30.02,"mount":"/","rw":null},{"fs":"/dev/disk1s2","type":"HFS","size":250685575168,"used":2173759488,"available":23591677952,"use":8.44,"mount":"/System/Volumes/Preboot","rw":null},{"fs":"/dev/disk1s4","type":"HFS","size":250685575168,"used":24576,"available":23591677952,"use":0,"mount":"/System/Volumes/VM","rw":null},{"fs":"/dev/disk1s6","type":"HFS","size":250685575168,"used":11665408,"available":23591677952,"use":0.05,"mount":"/System/Volumes/Update","rw":null},{"fs":"/dev/disk1s1","type":"HFS","size":250685575168,"used":213419753472,"available":23591677952,"use":90.05,"mount":"/System/Volumes/Data","rw":null}]
sebhildebrandt commented 6 months ago

@Zedbyte-corp can you pass the same drive parameter to the sample code above (outside electron)?

Zedbyte-corp commented 6 months ago

Add this entitlement

<key>com.apple.security.files.downloads.read-write</key>
<true/>

even though you have this

<key>com.apple.security.files.user-selected.read-write</key>
<true/>

the irony