Fixed: Check file extension when loading all
This commit is contained in:
parent
e02c66150c
commit
b4f87ca45c
1 changed files with 4 additions and 0 deletions
4
db.js
4
db.js
|
|
@ -49,6 +49,7 @@ function dbGet(table, id) {
|
||||||
let data = tableCache(table)[id];
|
let data = tableCache(table)[id];
|
||||||
if (data === undefined) {
|
if (data === undefined) {
|
||||||
if (fs.existsSync(file)) {
|
if (fs.existsSync(file)) {
|
||||||
|
console.log(`Loading ${table} with ID ${id} from disk: '${file}'`)
|
||||||
data = dbDeserialize(fs.readFileSync(file));
|
data = dbDeserialize(fs.readFileSync(file));
|
||||||
} else {
|
} else {
|
||||||
data = null;
|
data = null;
|
||||||
|
|
@ -68,6 +69,9 @@ function dbGetAll(table) {
|
||||||
const files = fs.readdirSync(dbDir(table));
|
const files = fs.readdirSync(dbDir(table));
|
||||||
const all = [];
|
const all = [];
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
|
if (!file.endsWith('.json')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const id = file.split('.')[0];
|
const id = file.split('.')[0];
|
||||||
const data = dbGet(table, id);
|
const data = dbGet(table, id);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue