Skip to content

Commit

Permalink
SDK: Fix FileExistsErrors on Windows when a dataset is loaded from …
Browse files Browse the repository at this point in the history
…cache

`atomic_writer` is supposed to overwrite the destination file, but
`os.rename` doesn't do that on Windows. We have to use `os.replace` instead.
  • Loading branch information
SpecLad committed Aug 21, 2023
1 parent 5889c43 commit 1724bfa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- TBD
- \[SDK\]: `FileExistsError` exception raised on Windows when a dataset is loaded from cache
(<https://github.com/opencv/cvat/pull/6722>)

### Security

Expand Down
2 changes: 1 addition & 1 deletion cvat-sdk/cvat_sdk/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def atomic_writer(
try:
with tmp_file:
yield tmp_file
os.rename(tmp_path, path)
os.replace(tmp_path, path)
except:
os.unlink(tmp_path)
raise

0 comments on commit 1724bfa

Please sign in to comment.