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 caching on windows #178

Merged
merged 6 commits into from
Dec 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ All versions prior to 0.0.9 are untracked.
the structure of source distributions was fixed
([#166](https://github.com/trailofbits/pip-audit/pull/166))

* Vulnerability sources: a performance issue on Windows caused by cache failures
was fixed ([#178](https://github.com/trailofbits/pip-audit/pull/178))

### Removed

## [1.0.1] - 2021-12-02
Expand Down
6 changes: 4 additions & 2 deletions pip_audit/_service/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def _set_impl(self, key: str, value: bytes) -> None:
except (IOError, OSError): # pragma: no cover
pass

# We don't want to use lock files since `pip` isn't going to recognise those. We should
# We don't want to use lock files since `pip` isn't going to recognize those. We should
# write to the cache in a similar way to how `pip` does it. We create a temporary file,
# then atomically replace the actual cache key's filename with it. This ensures
# that other concurrent `pip` or `pip-audit` instances don't read partial data.
Expand All @@ -82,7 +82,9 @@ def _set_impl(self, key: str, value: bytes) -> None:
io.flush()
os.fsync(io.fileno())

os.replace(io.name, name)
# NOTE(ww): Windows won't let us rename the temporary file until it's closed,
# which is why we call `os.replace()` here rather than in the `with` block above.
os.replace(io.name, name)

def delete(self, key: str) -> None: # pragma: no cover
try:
Expand Down