#Access is denied. (os error 5) when trying to re-read file

2 messages · Page 1 of 1 (latest)

royal hound
#

hello! i'm currently getting the IO error Access is denied. (os error 5) when trying to read a file from a command, after already reading it once successfully from the main function.

relevant info

  • GitHub Repository
  • OS - Windows 11, only tested on Windows as of now, as application doesn't really function on Linux/OSX yet

the file is initially read and seriailized into a struct from the main.rs file (as seen here) (normally, not giving any IO/permission error) and stored as state. my frontend can then go and "refresh" this state from a command (refresh_instances_index, as seen here), which in turn calls another function (get_instances_index_from_path, as seen here) to read it from the file system, causing this error.

i'm really not sure if the application is somehow just not "closing" the file or if it's some weird permission error, but i've been trying to fix this since yesterday, so any help would be appreciated! 💖

agile peak
#

It looks like the path is wrong. If i log the path in the function, it will print the instances/instances.index.json path from the main.rs call but from js it will print instances/ so you're trying to use a directory as a file which will also return os error 5