From 39f3796ba6a6d881b56db3fc17ad549b19e775ab Mon Sep 17 00:00:00 2001 From: Jim Tupper Date: Mon, 31 May 2021 17:21:14 +0100 Subject: [PATCH] Ensuring that we've stat'ed all the files we're considering --- lib/datestampedfileops.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/datestampedfileops.js b/lib/datestampedfileops.js index da501d2..aeabb90 100644 --- a/lib/datestampedfileops.js +++ b/lib/datestampedfileops.js @@ -89,9 +89,14 @@ function DateStampedFileOps(logpath, totalFiles, totalSize, gzip) { }); } + function filterUnstattedFiles(logstats, next) { + filteredlogstats = logstats.filter(logstat => logstat && logstat.stat && logstat.stat.mtime); + next(null, filteredlogstats); + } + function sortFilesByModifiedTime(logstats, next) { async.sortBy(logstats, function (logstat, next) { - next(null, -_.get(logstat,'stat.mtime')); + next(null, -logstat?.stat?.mtime); }, next); } @@ -141,6 +146,7 @@ function DateStampedFileOps(logpath, totalFiles, totalSize, gzip) { getFilesInLogDirectory, filterJustOurLogFiles(matchzippedfiles), statEachFile, + filterUnstattedFiles, sortFilesByModifiedTime ], function (err, logfiles) { next(err, logfiles);