Skip to content

Commit

Permalink
fix: "open_sublime_text_dir" command exception on Direct-IO disk
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jfcherng committed Apr 7, 2024
1 parent e76f096 commit abbd529
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 1 addition & 2 deletions plugin/commands/open_git_repo_on_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion plugin/commands/open_sublime_text_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down

0 comments on commit abbd529

Please sign in to comment.