diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 38ec79ff9..e63b47133 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,7 +29,7 @@ repos: - id: black - repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 + rev: 6.1.0 hooks: - id: flake8 diff --git a/echopype/utils/io.py b/echopype/utils/io.py index 0863b1537..3b93ee91e 100644 --- a/echopype/utils/io.py +++ b/echopype/utils/io.py @@ -5,6 +5,7 @@ import pathlib import platform import sys +import uuid from pathlib import Path, WindowsPath from typing import TYPE_CHECKING, Dict, Optional, Tuple, Union @@ -314,11 +315,12 @@ def check_file_existence(file_path: "PathHint", storage_options: Dict[str, str] def check_file_permissions(FILE_DIR): try: + fname = "." + str(uuid.uuid4()) if isinstance(FILE_DIR, FSMap): base_dir = os.path.dirname(FILE_DIR.root) if not base_dir: base_dir = FILE_DIR.root - TEST_FILE = os.path.join(base_dir, ".permission_test").replace("\\", "/") + TEST_FILE = os.path.join(base_dir, fname).replace("\\", "/") with FILE_DIR.fs.open(TEST_FILE, "w") as f: f.write("testing\n") FILE_DIR.fs.delete(TEST_FILE) @@ -329,7 +331,7 @@ def check_file_permissions(FILE_DIR): if not FILE_DIR.exists(): logger.warning(f"{str(FILE_DIR)} does not exist. Attempting to create it.") FILE_DIR.mkdir(exist_ok=True, parents=True) - TEST_FILE = FILE_DIR.joinpath(Path(".permission_test")) + TEST_FILE = FILE_DIR.joinpath(Path(fname)) TEST_FILE.write_text("testing\n") # Do python version check since missing_ok is for python 3.9 and up