Skip to content

Commit

Permalink
Ensuring that we've stat'ed all the files we're considering
Browse files Browse the repository at this point in the history
  • Loading branch information
Rcomian committed May 31, 2021
1 parent 1c9bf4b commit 39f3796
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/datestampedfileops.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -141,6 +146,7 @@ function DateStampedFileOps(logpath, totalFiles, totalSize, gzip) {
getFilesInLogDirectory,
filterJustOurLogFiles(matchzippedfiles),
statEachFile,
filterUnstattedFiles,
sortFilesByModifiedTime
], function (err, logfiles) {
next(err, logfiles);
Expand Down

0 comments on commit 39f3796

Please sign in to comment.