MasoniteFramework/masonite

FileDriver permission issue

Closed this issue · 0 comments

Describe the bug

inside get() method, there is a call to forget() method within "with open(....) as f:". however, in forget() method the same file refered by "f" may need to be deleted if cache expired. Because the file is still open within "with..." clause, the system raise PermissionError (WinError 32]. Has to close the file before it can be removed.

Expected behaviour

no PersmissionError

Steps to reproduce the bug

No response

Screenshots

PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'storage/framework/cache\1e8c92e34597e2cac4af38381539d117-timer'

~/vscspace\myproject\venv\lib\site-packages\masonite\cache\drivers\FileDriver.py: L74 in forget()

65 | value = self.get(key)
66 |
67 | if value:
68 | return value
69 |
70 | callable(self)
71 |
72 | def forget(self, key):
73 | try:

74 | os.remove(os.path.join(self._get_directory(), key))
75 | return True
76 | except FileNotFoundError:
77 | return False

OS

Windows

OS version

Windows 11

Browser

Chrome

Masonite Version

4.6.1

Anything else ?

No response