Closed jakeershareef closed 8 months ago
Please provide the code that throws the error
Windows:
Error: EPERM: operation not permitted, rename 'C:\Users\shaonhuang\AppData\Roaming\v2rayx\lowdb\.db.json.tmp' -> 'C:\Users\shaonhuang\AppData\Roaming\v2rayx\lowdb\db.json'
my code runs like the below
lowdb file
const userData = app.getPath('userData');
const dbPath = join(userData, 'lowdb', 'db.json');
const parentDir = join(userData, 'lowdb');
if (!existsSync(parentDir)) {
mkdirSync(parentDir);
}
const adapter = new JSONFile<Data>(dbPath);
const db = new LowWithLodash(adapter, defaultData);
export default db;
Linux shows it too.
ENOENT: no such file or directory, rename '/home/xxxx/snap/v2rayx/307/.config/v2rayx/lowdb/.db.json.tmp' -> '/home/xxxx/snap/v2rayx/307/.config/v2rayx/lowdb/db.json'
await db.read();
db.data = db.chain.set('appVersion', app.getVersion()).value();
await db.write();
Getting the same error. It has lasted for a long time. and still not fixing.
It's happening here. Typical atomic write AFAIK. https://github.com/typicode/steno/blob/main/src/index.ts#L47-L48
I don't know why it's failing, sorry about that. But the code is tested with 1000 concurrent writes here: https://github.com/typicode/steno/blob/main/src/test.ts
Feel free to create a failing test in a PR (and optionally a fix) as I really don't know why it's occuring :thinking:
v7 should fix it, let me know if it's not the case
v7 should fix it, let me know if it's not the case
Error: ENOENT: no such file or directory, open 'C:\Users\xxxx\AppData\Roaming\v2rayx\lowdb.dbv4.json.tmp'
issue still exists in the new version.
Hmm, could you try disabling your antivirus? Is it an old hard drive or big db.json or are you doing a lot of writes?
Can you go to node_modules/steno/lib/index.js
and change this value from 100 to 1000? This will try to rename tmp file 10 times with an interval of 1000ms instead of 100ms. Giving more time maybe for the system to scan this file.
https://github.com/typicode/steno/blob/main/src/index.ts#L73
i am getting error Error in splitPdfPathHandler: [Error: ENOENT: no such file or directory, rename 'C:\Users\jakee\OneDrive\Desktop\lis-scan-docs\desktop-scan-docs\db.scan.json.tmp' -> 'C:\Users\jakee\OneDrive\Desktop\lis-scan-docs\desktop-scan-docs\db\scan.json'] { errno: -4058, code: 'ENOENT', syscall: 'rename', path: 'C:\Users\jakee\OneDrive\Desktop\lis-scan-docs\desktop-scan-docs\db\.scan.json.tmp', dest: 'C:\Users\jakee\OneDrive\Desktop\lis-scan-docs\desktop-scan-docs\db\scan.json' }
when i try to save the data in lowdb i am getting above error. i am using version 6.1.1. i also not understand how to delete data from lowdb array of objects.