Skip to content

Commit

Permalink
Merge pull request #1 from benirose/master
Browse files Browse the repository at this point in the history
Fix issue where we were matching file names poorly for deletion.
  • Loading branch information
mkopinsky authored Feb 17, 2018
2 parents 87a31c7 + 2be02bf commit 11c0fd9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion albedo.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ function rmDir(dirPath, options) {
const now = moment().unix();
const daysAgo = now - (parseInt(options.removeOlderThan, 10) * 86400);
const fileTime = moment(fs.statSync(filePath).mtime).unix();
if (fileName.substring(0, options.name.length) === options.name) {
// get the full name of the report from the file by removing the datetime and extension
if (fileName.slice(0, 0-'_YYYY-MM-DD_HH-mm-ss.csv'.length) === options.name) {
if (fileTime < daysAgo) {
fs.unlinkSync(filePath);
console.log(`deleted: ${filePath}`);
Expand Down

0 comments on commit 11c0fd9

Please sign in to comment.