A
A
andreyka_g2015-04-05 14:14:50
JavaScript
andreyka_g, 2015-04-05 14:14:50

How to fix: Error: EPERM, lstat 'e:\System Volume Information' at Error (native)?

Hello! Trying to write an application to search for files on a computer, I encountered such an error

Error: EPERM, lstat 'e:\System Volume Information' at Error (native)

The application is written using node-webkit and the node-findit module . To implement the search, you need to specify the root of the file system (well, or disk, for starters).
The complete js code looks like this:
var find = require('findit');
var finder = require('findit')('/'); // тут я и задаю корень. тут-то и выдается ошибка
var path = require('path');
finder.on('directory', function (dir, stat, stop) {
    var base = path.basename(dir);
    if (base === '.git' || base === 'node_modules' || base === '.sass-cache' ) stop() //base === 'System Volume Information' - не помогло
    else console.log(dir + '/')
});
var files = [];
var wh = $('.search').val(); // .search - поле, куда вводится искомый файл
var rx = new RegExp(wh, "g"); // регулярка для поиска по фрагменту
finder.on('file', function (file, stat) {
    files.push(file);
});
$('.js-find').click(function() {
  for(var i = 0; i < files.length; i++) {
    if(files[i].match(rx)) console.log(files[i]); // найденные файлы выводятся в консоль
  }
});

I understand that I have access to the "System Volume Information" folder, which in turn is engaged in system recovery, but even bypassing the condition does not help. I do not consider it right to open access, since the application needs to be run on different computers.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timur Shemsedinov, 2015-04-05
@andreyka_g

According to the link that you gave and there is a solution, tk. on a broom there may be files and directories with different access rights, then you need to select EPERM errors from the general stream and ignore them. Completely ignore errors: finder.on('error', function (err) {}); If you jam only EPERM, then probably like this:

finder.on('error', function (err) {
    if (err.code !== 'EPERM') finder.stop();
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question