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 (cvat-ai#6722)

`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 23, 2023
1 parent 8e55dbd commit a6a2782
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Removing job assignee (<https://github.com/opencv/cvat/pull/6712>)
- Fixed switching from organization to sandbox while getting a resource (<https://github.com/opencv/cvat/pull/6689>)
- \[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 a6a2782

Please sign in to comment.