Mar-22-2022, 05:21 PM
I asked this question over on StackOverflow this morning, but don't seem to be having much luck in terms of Python help as most seem to think of it as something to do with my computer, so figured I might have more luck here.
I am creating a small utility that can be used to download and install updates for games that don't run through storefronts that automate the process. For the most part, it's been working perfectly!
As part of the testing, we've discovered that hidden files seem to confound the extraction process. It consistently results in this error:
Am I right in thinking that this means there's no way to proceed from here using the zipfile module? In any case, any suggestions on how to proceed are certainly welcome!
The relevant section of code I'm using is as follows:
I am creating a small utility that can be used to download and install updates for games that don't run through storefronts that automate the process. For the most part, it's been working perfectly!
As part of the testing, we've discovered that hidden files seem to confound the extraction process. It consistently results in this error:
Error:PermissionError: [Errno 13] Permission denied: 'E:\path\hidden.txt'
I wasn't able to find much in the way of hidden files and Python interacting, but I did find this old question noting that Python itself is unable to handle hidden files in "standard" modes (like r, w, etc) due to how the underlying Win32 API is used. I tried using a similar solution for my code but had no luck. I dug a bit into the zipfile module itself to see what I could find and noticed this:Quote:mode: The mode can be either read 'r', write 'w', exclusive create 'x', or append 'a'.
Am I right in thinking that this means there's no way to proceed from here using the zipfile module? In any case, any suggestions on how to proceed are certainly welcome!
The relevant section of code I'm using is as follows:
updateFile = zipfile.ZipFile(updateTarget, 'r') updateFile.extractall() updateFile.close()And the full traceback is as follows:
Error:Traceback (most recent call last):
File "E:\Python 3.10\lib\threading.py", line 1009, in _bootstrap_inner
self.run()
File "E:\Python 3.10\lib\threading.py", line 946, in run
self._target(*self._args, **self._kwargs)
File "E:\Git Repos\Prelude\main.py", line 74, in updateGame
updateAction(config.patchArchive, 'patch')
File "E:\Git Repos\Prelude\main.py", line 115, in updateAction
if (errorHandling.localCheck(updateTarget) == False):
File "E:\Git Repos\Prelude\errorHandling.py", line 26, in localCheck
updateFile.extractall()
File "E:\Python 3.10\lib\zipfile.py", line 1634, in extractall
self._extract_member(zipinfo, path, pwd)
File "E:\Python 3.10\lib\zipfile.py", line 1688, in _extract_member
open(targetpath, "wb") as target:
PermissionError: [Errno 13] Permission denied: 'E:\\Git Repos\\Prelude\\hidden.txt'
Using the above code results in that traceback. I've also tried the other three available modes in zipfile just to be thorough and nothing. Additionally, I've tried running it as an administrator and there are no file ownership issues. I did notice with some testing that if the file to be overwritten is not set as hidden, it will proceed fine, but the resultant file will not be hidden (even though the downloaded zip definitely has that file set to hidden). Ideally, the unzip process would proceed as normally and overwrite the hidden files. If that's not possible with zipfile, does anyone have recommendations on how to go about this?