Closed ratanservegar closed 1 year ago
The error is coming from https://github.com/fabiospampinato/atomically, so you should open an issue there instead.
It's worth exploring switching to asynchronous writing rather than synchronous writing, as that gives atomically more time to retry operations, as in sync mode it will keep retrying operations for up to 1s, but in async mode it will try for up to 7.5s.
Other than that if Windows decides that a rename just is not allowed there's no way to perform an atomic write, so no way to fix this in atomically.
@fabiospampinato thanks for the reply, could you tell me how to change to async? is this something electron-store needs to implement or can i do it just for my app?
@sindresorhus seems like it something that needs to be done in electron-store, is this something you can accommodate? Thanks!
Can you reopen it please? My project is also facing the same issue.
Hi,
I have a stored named MasterStore and it creates a MasterStore.json files and everything works prefect. However, after sometime for some reason the .setCache function errors out because it is trying to access some MasterStore.json.temp file. below is the error log
Error: EPERM: operation not permitted, rename 'C:\Users\AppData\Roaming\neclient\MasterStore.json.tmp-900921090850e765' -> 'C:\Users\AppData\Roaming\neclient\MasterStore.json' at renameSync (node:fs:993:3) at attempt (C:\Users\AppData\Local\Programs\neclient\resources\app\node_modules\atomically\dist\utils\retryify.js:33:27) at attempt (C:\Users\AppData\Local\Programs\neclient\resources\app\node_modules\atomically\dist\utils\retryify.js:39:36) at attempt (C:\Users\AppData\Local\Programs\neclient\resources\app\node_modules\atomically\dist\utils\retryify.js:39:36) at Object.writeFileSync (C:\Users\AppData\Local\Programs\neclient\resources\app\node_modules\atomically\dist\index.js:160:50) at ElectronStore._write (C:\Users\AppData\Local\Programs\neclient\resources\app\node_modules\conf\dist\source\index.js:375:28) at set store [as store] (C:\Users\AppData\Local\Programs\neclient\resources\app\node_modules\conf\dist\source\index.js:296:14) **at ElectronStore.set (C:\Users\AppData\Local\Programs\neclient\resources\app\node_modules\conf\dist\source\index.js:189:20) at Object.setCacheValue (C:\Users\AppData\Local\Programs\neclient\resources\app\system_services\cache-service.js:59:21)** at BeforeAppShutDown (C:\Users\AppData\Local\Programs\neclient\resources\app\main.js:352:23)
i crate the store using
const masterStore = new Store({ name: 'MasterStore' });
and set contents bymasterStore.set(key, value);
can someone tell me whats the reason its doing this? and how i can fix it?