From 5008fe0d2927b5509264899a2c2c1243e22132f3 Mon Sep 17 00:00:00 2001 From: lihsai0 Date: Mon, 30 Sep 2024 14:31:21 +0800 Subject: [PATCH] fix: cache file write error on windows --- .github/workflows/ci-test.yml | 3 ++- qiniu/http/regions_provider.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml index c705019b..f907754c 100644 --- a/.github/workflows/ci-test.yml +++ b/.github/workflows/ci-test.yml @@ -6,8 +6,9 @@ jobs: fail-fast: false max-parallel: 1 matrix: + os: ['ubuntu-20.04', 'windows-2019'] python_version: ['2.7', '3.4', '3.5', '3.6', '3.7', '3.8', '3.9'] - runs-on: ubuntu-20.04 + runs-on: ${{ matrix.os }} steps: - name: Checkout repo uses: actions/checkout@v2 diff --git a/qiniu/http/regions_provider.py b/qiniu/http/regions_provider.py index 8b52822c..787162e5 100644 --- a/qiniu/http/regions_provider.py +++ b/qiniu/http/regions_provider.py @@ -5,6 +5,7 @@ import logging import tempfile import os +import shutil from qiniu.compat import json, b as to_bytes from qiniu.utils import io_md5 @@ -655,7 +656,7 @@ def __shrink_cache(self): ) # rename file - os.rename(shrink_file_path, self._cache_scope.persist_path) + shutil.move(shrink_file_path, self._cache_scope.persist_path) except FileAlreadyLocked: pass finally: