Opened 5 years ago
Last modified 22 months ago
#30603 closed Bug
Stored file locking issue when using Django on Windows and youtube_dl package is installed — at Initial Version
Reported by: | ManicEatsWorld | Owned by: | nobody |
---|---|---|---|
Component: | File uploads/storage | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Kevin Christopher Henry | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When using the FileSystemStorage.save() functions in a Windows installation of Django with the youtube_dl package installed, an error is thrown in locks.py upon trying to unlock the newly stored file:
Internal Server Error: / Traceback (most recent call last): File "<<Project base directory removed for privacy>>\venv\lib\site-packages\django\core\files\move.py", line 61, in file_move_safe locks.lock(fd, locks.LOCK_EX) File "<<Project base directory removed for privacy>>\venv\lib\site-packages\django\core\files\locks.py", line 80, in lock ret = LockFileEx(hfile, flags, 0, 0, 0xFFFF0000, byref(overlapped)) ctypes.ArgumentError: argument 6: <class 'TypeError'>: expected LP_OVERLAPPED instance instead of pointer to OVERLAPPED During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<<Project base directory removed for privacy>>\venv\lib\site-packages\django\core\handlers\exception.py", line 34, in inner response = get_response(request) File "<<Project base directory removed for privacy>>\venv\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "<<Project base directory removed for privacy>>\venv\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "<<Project base directory removed for privacy>>\GenreClassificationWeb\webClassification\views.py", line 29, in upload name = fs.save(uploaded_file.name, uploaded_file) File "<<Project base directory removed for privacy>>\venv\lib\site-packages\django\core\files\storage.py", line 52, in save return self._save(name, content) File "<<Project base directory removed for privacy>>\venv\lib\site-packages\django\core\files\storage.py", line 261, in _save file_move_safe(content.temporary_file_path(), full_path) File "<<Project base directory removed for privacy>>\venv\lib\site-packages\django\core\files\move.py", line 67, in file_move_safe locks.unlock(fd) File " <<Project Directory>>\venv\lib\site-packages\django\core\files\locks.py", line 86, in unlock ret = UnlockFileEx(hfile, 0, 0, 0xFFFF0000, byref(overlapped)) ctypes.ArgumentError: argument 5: <class 'TypeError'>: expected LP_OVERLAPPED instance instead of pointer to OVERLAPPED
Removing the youtube_dl package does immediately resolve this issue. Sadly, youtube-dl is necessary for this project due to a lack of working cross-platform alternatives.
This issue has been recreated with a Windows 10 and a Windows 7 machine using different VENVs.
I do believe this is a bug and will cross-post an issue at the youtube-dl issue page.