mirror of
https://github.com/remotely-save/remotely-save.git
synced 2024-06-07 21:10:45 +00:00
buck? localforage
This commit is contained in:
parent
d1e30e3536
commit
cb98bae79a
@ -77,6 +77,7 @@
|
|||||||
"http-status-codes": "^2.3.0",
|
"http-status-codes": "^2.3.0",
|
||||||
"localforage": "^1.10.0",
|
"localforage": "^1.10.0",
|
||||||
"localforage-getitems": "^1.4.2",
|
"localforage-getitems": "^1.4.2",
|
||||||
|
"localforage-removeitems": "^1.4.0",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"lucide": "^0.376.1",
|
"lucide": "^0.376.1",
|
||||||
"mime-types": "^2.1.35",
|
"mime-types": "^2.1.35",
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import localforage from "localforage";
|
import localforage from "localforage";
|
||||||
import { extendPrototype } from "localforage-getitems";
|
import { extendPrototype as ep1 } from "localforage-getitems";
|
||||||
extendPrototype(localforage);
|
import { extendPrototype as ep2 } from "localforage-removeitems";
|
||||||
|
ep1(localforage);
|
||||||
|
ep2(localforage);
|
||||||
export type LocalForage = typeof localforage;
|
export type LocalForage = typeof localforage;
|
||||||
import { nanoid } from "nanoid";
|
import { nanoid } from "nanoid";
|
||||||
|
|
||||||
@ -307,12 +309,15 @@ export const clearFileHistoryOfEverythingByVault = async (
|
|||||||
db: InternalDBs,
|
db: InternalDBs,
|
||||||
vaultRandomID: string
|
vaultRandomID: string
|
||||||
) => {
|
) => {
|
||||||
const keys = await db.fileHistoryTbl.keys();
|
const keys = (await db.fileHistoryTbl.keys()).filter((x) =>
|
||||||
for (const key of keys) {
|
x.startsWith(`${vaultRandomID}\t`)
|
||||||
if (key.startsWith(`${vaultRandomID}\t`)) {
|
);
|
||||||
await db.fileHistoryTbl.removeItem(key);
|
await db.fileHistoryTbl.removeItems(keys);
|
||||||
}
|
// for (const key of keys) {
|
||||||
}
|
// if (key.startsWith(`${vaultRandomID}\t`)) {
|
||||||
|
// await db.fileHistoryTbl.removeItem(key);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -339,12 +344,15 @@ export const clearAllSyncMetaMappingByVault = async (
|
|||||||
db: InternalDBs,
|
db: InternalDBs,
|
||||||
vaultRandomID: string
|
vaultRandomID: string
|
||||||
) => {
|
) => {
|
||||||
const keys = await db.syncMappingTbl.keys();
|
const keys = (await db.syncMappingTbl.keys()).filter((x) =>
|
||||||
for (const key of keys) {
|
x.startsWith(`${vaultRandomID}\t`)
|
||||||
if (key.startsWith(`${vaultRandomID}\t`)) {
|
);
|
||||||
await db.syncMappingTbl.removeItem(key);
|
await db.syncMappingTbl.removeItems(keys);
|
||||||
}
|
// for (const key of keys) {
|
||||||
}
|
// if (key.startsWith(`${vaultRandomID}\t`)) {
|
||||||
|
// await db.syncMappingTbl.removeItem(key);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
export const insertSyncPlanRecordByVault = async (
|
export const insertSyncPlanRecordByVault = async (
|
||||||
@ -422,11 +430,12 @@ export const clearExpiredSyncPlanRecords = async (db: InternalDBs) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const ps = [] as Promise<void>[];
|
// const ps = [] as Promise<void>[];
|
||||||
keysToRemove.forEach((element) => {
|
// keysToRemove.forEach((element) => {
|
||||||
ps.push(db.syncPlansTbl.removeItem(element));
|
// ps.push(db.syncPlansTbl.removeItem(element));
|
||||||
});
|
// });
|
||||||
await Promise.all(ps);
|
// await Promise.all(ps);
|
||||||
|
await db.syncPlansTbl.removeItems(Array.from(keysToRemove));
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAllPrevSyncRecordsByVaultAndProfile = async (
|
export const getAllPrevSyncRecordsByVaultAndProfile = async (
|
||||||
@ -475,12 +484,10 @@ export const clearAllPrevSyncRecordByVault = async (
|
|||||||
db: InternalDBs,
|
db: InternalDBs,
|
||||||
vaultRandomID: string
|
vaultRandomID: string
|
||||||
) => {
|
) => {
|
||||||
const keys = await db.prevSyncRecordsTbl.keys();
|
const keys = (await db.prevSyncRecordsTbl.keys()).filter((x) =>
|
||||||
for (const key of keys) {
|
x.startsWith(`${vaultRandomID}\t`)
|
||||||
if (key.startsWith(`${vaultRandomID}\t`)) {
|
);
|
||||||
await db.prevSyncRecordsTbl.removeItem(key);
|
await db.prevSyncRecordsTbl.removeItems(keys);
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const clearAllLoggerOutputRecords = async (db: InternalDBs) => {
|
export const clearAllLoggerOutputRecords = async (db: InternalDBs) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user