Major version update. Major bugfixes. Security vulnerabilites fixed
This commit is contained in:
Vendored
+12
-5
@@ -1,18 +1,25 @@
|
||||
import grabDBDir from "../utils/grab-db-dir";
|
||||
import fs from "fs";
|
||||
import _ from "lodash";
|
||||
export default function grabSortedBackups({ config }) {
|
||||
const { backup_dir } = grabDBDir({ config });
|
||||
const backups = fs.readdirSync(backup_dir);
|
||||
if (!fs.existsSync(backup_dir))
|
||||
return [];
|
||||
/**
|
||||
* Only files named by `grabDBBackupFileName` for this database. Anything
|
||||
* else in the directory is never listed (or trimmed).
|
||||
*/
|
||||
const backup_name_regex = new RegExp(`^${_.escapeRegExp(config.db_name)}-\\d+$`);
|
||||
const backups = fs
|
||||
.readdirSync(backup_dir)
|
||||
.filter((b) => backup_name_regex.test(b));
|
||||
/**
|
||||
* Order Backups. Most recent first.
|
||||
*/
|
||||
const ordered_backups = backups.sort((a, b) => {
|
||||
const a_date = Number(a.split("-").pop());
|
||||
const b_date = Number(b.split("-").pop());
|
||||
if (a_date > b_date) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
return b_date - a_date;
|
||||
});
|
||||
return ordered_backups;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user