Skip to content

Commit

Permalink
Merge pull request #652 from prey/fix-file-retrieval-when-directory-i…
Browse files Browse the repository at this point in the history
…s-empty

validation when directory is empty
  • Loading branch information
SoraKenji authored Aug 1, 2022
2 parents b01a5ec + fe5457e commit e7a2e88
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/agent/providers/files/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@

var fs = require('fs'),
path = require('path'),
mime = require('mime'),
execSync = require("child_process").execSync;

var common = require('./../../common'),
system = common.system,
logger = common.logger,
logger = common.logger.prefix('files'),
node_bin = path.join(system.paths.current, 'bin', 'node'),
run_as_user = common.system.run_as_user,
finder = require('./finder'),
Expand Down Expand Up @@ -77,7 +76,7 @@ var get_list = function(options, callback) {
matches = [];

if (!path)
return cb(new Error('Cannot find files without a path.'));
return callback(new Error('Cannot find files without a path.'));

fs.exists(path, function(exists) {
if (!exists)
Expand Down Expand Up @@ -151,6 +150,11 @@ module.exports.get_tree = function(options, cb) {
return cb(new Error('Unable to parse files data'));
}

if (files.length == 0) {
logger.info("without files in folder!");
return cb(null, "[]");
}

files.forEach((file, index) => {
var done = (isHidden) => {
file.hidden = isHidden;
Expand Down

0 comments on commit e7a2e88

Please sign in to comment.