Skip to content

Commit

Permalink
fix: 创建配置文件可能失败的错误
Browse files Browse the repository at this point in the history
与图形化软件`up2b`一起使用时,可能会在不存在的`up2b/conf`目录中创建文件而报错。
  • Loading branch information
thep0y committed Mar 20, 2024
1 parent 600d417 commit 9e945d1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ readme = "README.md"
requires-python = ">=3"
license = { file = "LICENSE" }
classifiers = ["Programming Language :: Python :: 3"]
keywords = ["typora", "image bed", "upload"]
keywords = ["typora", "image bed", "upload", "picture bed", "图床"]
dependencies = [
"requests",
"click",
Expand Down Expand Up @@ -45,9 +45,9 @@ write_to = "up2b/version.py"

[tool.black]
line-length = 88
target-version = ['py36', 'py37', 'py38', 'py39', 'py310', 'py311']
target-version = ['py36', 'py37', 'py38', 'py39', 'py310', 'py311', "py312"]
include = '\.pyi?$'

[tool.pyright]
pythonVersion = '3.11'
pythonVersion = '3.12'
venv = 'dev'
4 changes: 4 additions & 0 deletions up2b/up2b_lib/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,9 @@ def __str__(self) -> str:
os.makedirs(CONFIG_FOLDER_PATH / "conf", 0o755)

CONF_FILE = CONFIG_FOLDER_PATH / "conf" / "conf.up2b.json"

if not CONF_FILE.parent.exists():
CONF_FILE.parent.mkdir(parents=True)

CACHE_PATH = Path(gettempdir()) / "up2b"
CACHE_DATABASE = CONFIG_FOLDER_PATH / "cache.db"
1 change: 1 addition & 0 deletions up2b/up2b_lib/up2b_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def choose_image_bed(image_bed_code: int):
raise TypeError(
"image bed code must be an integer, not %s" % str(type(image_bed_code))
)

try:
with open(CONF_FILE, "r+") as f:
conf = json.loads(f.read())
Expand Down

0 comments on commit 9e945d1

Please sign in to comment.