Closed stanleyyang2001 closed 8 months ago
@stanleyyang2001 What is the progress on making the requested changes?
@loganwyas it's done, only review is required
@stanleyyang2001 I made a comment 12 days ago about a hardcoded directory being used, and I notice that it hasn't been fixed.
@loganwyas odd, I didn't find the comment. Can you point out the directory with the problem again?
@loganwyas It's fixed now, still some hard code left since the protected file opened by mouser doesn't points to the actual protected file.
Fixes #168
What was changed?
Nothing was changed currently, but problems were identified. There are two possible errors that could occur when trying to access protected experiment files:
If the first time the password is incorrect when opening the file, then that means the file path that got passed to the password manager isn't byte, which gives error when trying to read from the file. However, I rarely encounter this error, and the next error is the main problem of this issue, so I put the possible error here in case someone else encounters this problem in the future and needs a reference.
if the password is incorrect the second time a user tries to access the file after opening it for the first time, then it's the problem of the database of the previous temporary file hasn't been closed yet, which gives the error: "The process cannot access the file because it is being used by another process: 'C:\Users\\_username\Local\Temp\Mouser\test password_Protected.mouser'", to solve this problem, the database should be disconnected from the database after the user exit out of the protected file. However, I couldn't figure out the exact way to accomplish this task, so I use another method, which is to remove the directory containing the temporary file every time the mouser application starts.
Why was it changed?
The error arose because whenever a protected file was opened, a temporary file with all method that the actual file would have is created in a temporary mouser directory, and the application would use that file instead of the actual file. This means that the application is creating duplicate files in the temporary directory, which takes up the memory of the PC. Therefore, the original approach to reduce the resources use was to check if a duplicate file already exists and if it does, the application will remove the file. However, every time the temporary file is created it is connected to the database, and there's no method that's currently implemented to disconnect a mouser file from the database when it's not being used by the mouser application. This makes it so that even if the user moves on to another mouser file, the database is still connected to the temporary file, and evoke the error when the application tries to remove it.
How was it changed? I added a check in main.py that checks if there's a "Mouser" directory in the AppData/Local/Temp, if there is, then the application will delete that directory. I also added a check so that if there's a temporary file already existed in the temporary directory, then there's no need to create a new temporary file and writes data to it since we can use the existing file.