From dd862f27b794a70cfaf2f18dca8a7fa11c3e7bd0 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Wed, 16 Aug 2023 19:10:52 +0300 Subject: [PATCH] SDK: Fix `FileExistsError`s on Windows when a dataset is loaded from 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. --- cvat-sdk/cvat_sdk/core/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cvat-sdk/cvat_sdk/core/utils.py b/cvat-sdk/cvat_sdk/core/utils.py index 1708dfd5779a..9aadd90cc8c2 100644 --- a/cvat-sdk/cvat_sdk/core/utils.py +++ b/cvat-sdk/cvat_sdk/core/utils.py @@ -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