Fix a bug when downloading new Liquibase version on Windows temp dir #57
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 withdelete
argument toTrue
. I fixed the issue by forcingdelete
toFalse
when constructing theNamedTemporaryFile
object and then delete it withos.unlink()
method.