nut icon indicating copy to clipboard operation
nut copied to clipboard

[Feature] Auto scan intervals

Open scottybuk opened this issue 3 years ago • 2 comments

Hi, I use NUT on my windows server with gdrive mounted to that machine to serv the files remotely to my tinfoil at home.

I have to manually press the scan button every day to pick up new files, an option to have this automatically rescan would be awesome, thanks.

scottybuk avatar Oct 31 '21 11:10 scottybuk

Call the scan api periodically https://github.com/blawar/nut/blob/master/Server/Controller/Api.py#L84

bd82aa5c1aaecdb2559d avatar Oct 31 '21 14:10 bd82aa5c1aaecdb2559d

Call the scan api periodically https://github.com/blawar/nut/blob/master/Server/Controller/Api.py#L84 after looking into this some, I see what you mean. i will see if I can do this via a timed batch file, thanks.

i think the API requests should be documented more <3

scottybuk avatar Nov 01 '21 09:11 scottybuk

If you're using nodejs and have the nut server running, for example:

function apiCall(path){
  return new Promise((resolve, reject) => {
    axios({
      method:'get',
      url:`http://127.0.0.1:${NUT_PORT}/api/${path}`,
      auth: {
        username: config.NUT_USER,
        password: config.NUT_PASS
      },
    })
    .then(function (response) {
      resolve(response.data);
    })
    .catch(function (error) {
      reject(error);
    });
  })
}
  console.log('Scanning local nut files...')
  try{
    await apiCall('scan')
  }catch (e) {
    console.error('Failed', e)
  }

bd82aa5c1aaecdb2559d avatar Nov 03 '21 13:11 bd82aa5c1aaecdb2559d

I'll second adding autoscan. Having to run an external script to trigger scanning is not always feasible.

falnos24865 avatar Dec 20 '21 19:12 falnos24865