Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug when downloading new Liquibase version on Windows temp dir #57

Merged
merged 1 commit into from Jul 1, 2023

Conversation

alexandredenis-bib
Copy link
Contributor

I was getting the following error message after upgrading my pyliquibase package from 2.0.11 to 2.0.12:

2023-06-30 17:34:32,309 - WARNING - Downloading Liquibase version: 4.21.1 ...
2023-06-30 17:34:32,310 - INFO - Downloading https://github.com/liquibase/liquibase/releases/download/v4.21.1/liquibase-4.21.1.zip to C:\Users\alexa\Envs\falcon-db\lib\site-packages\pyliquibase\liquibase-4.21.1
url = https://github.com/liquibase/liquibase/releases/download/v4.21.1/liquibase-4.21.1.zip
destination = C:\Users\alexa\AppData\Local\Temp\tmpw76m_sqg_liquibase.zip
2023-06-30 17:34:32,929 - ERROR - Failed to download https://github.com/liquibase/liquibase/releases/download/v4.21.1/liquibase-4.21.1.zip
Unable to update database falcon-auth through liquibase
Traceback (most recent call last):
File ".\initdb.py", line 111, in liquibase_update
liquibase = Pyliquibase(
File "C:\Users\alexa\Envs\falcon-db\lib\site-packages\pyliquibase_init_.py", line 87, in init
self.download_liquibase()
File "C:\Users\alexa\Envs\falcon-db\lib\site-packages\pyliquibase_init
.py", line 196, in _download_liquibase
self.download_zipfile(url=LIQUIBASE_ZIP_URL.format(self.version, self.version),
File "C:\Users\alexa\Envs\falcon-db\lib\site-packages\pyliquibase_init
.py", line 240, in _download_zipfile
self.download_file(url, tmpfile.name)
File "C:\Users\alexa\Envs\falcon-db\lib\site-packages\pyliquibase_init
.py", line 257, in download_file
raise e
File "C:\Users\alexa\Envs\falcon-db\lib\site-packages\pyliquibase_init
.py", line 254, in _download_file
request.urlretrieve(url, destination)
File "c:\python38\lib\urllib\request.py", line 257, in urlretrieve
tfp = open(filename, 'wb')
PermissionError: [Errno 13] Permission denied: 'C:\Users\alexa\AppData\Local\Temp\tmpw76m_sqg_liquibase.zip'

After some researches, I found that the issue was due to a permission problem on Windows when constructing a NamedTemporaryFile object with delete argument to True. I fixed the issue by forcing delete to False when constructing the NamedTemporaryFile object and then delete it with os.unlink() method.

@ismailsimsek ismailsimsek merged commit de5ef34 into memiiso:master Jul 1, 2023
7 checks passed
@ismailsimsek
Copy link
Member

merged thank you @alexandredenis-bib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants