From abbd529ce2bc7db9ea7c236ca510818a3bbbad42 Mon Sep 17 00:00:00 2001 From: Jack Cherng Date: Sun, 7 Apr 2024 20:08:57 +0800 Subject: [PATCH] fix: "open_sublime_text_dir" command exception on Direct-IO disk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I set my TEMP dir to a Direct-IO disk created by a Ramdisk software. And "path.resolve()" failed on that disk. OSError: [WinError 1] 功能錯誤。: 'R:\\TEMP-J~1\\..' Signed-off-by: Jack Cherng --- plugin/commands/open_git_repo_on_web.py | 3 +-- plugin/commands/open_sublime_text_dir.py | 10 +++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/plugin/commands/open_git_repo_on_web.py b/plugin/commands/open_git_repo_on_web.py index 40ee0b0..52acf22 100644 --- a/plugin/commands/open_git_repo_on_web.py +++ b/plugin/commands/open_git_repo_on_web.py @@ -5,10 +5,9 @@ import shutil import subprocess import threading -from collections.abc import Callable from functools import wraps from pathlib import Path -from typing import Any, TypeVar, cast +from typing import Any, Callable, TypeVar, cast import sublime import sublime_plugin diff --git a/plugin/commands/open_sublime_text_dir.py b/plugin/commands/open_sublime_text_dir.py index 530116b..227b50b 100644 --- a/plugin/commands/open_sublime_text_dir.py +++ b/plugin/commands/open_sublime_text_dir.py @@ -7,16 +7,24 @@ import sublime import sublime_plugin +assert __package__ + PACKAGE_NAME = __package__.partition(".")[0] @lru_cache def _get_folder_map() -> dict[str, str]: + def resolve_path(path: Path) -> Path: + try: + return path.resolve() # will fail on a Direct-IO disk + except OSError: + return path + cache_path = Path(sublime.cache_path()) packages_path = Path(sublime.packages_path()) return { - name: str(path.resolve()) + name: str(resolve_path(path)) for name, path in ( # from OS ("home", Path.home()),