Skip to content

Commit 48be54c

Browse files
committed
fix cache_dir
1 parent 3309653 commit 48be54c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/wechaty/plugin.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ def __init__(self, options: Optional[WechatyPluginOptions] = None):
393393
options = WechatyPluginOptions()
394394
self.options = options
395395
self._default_logger: Optional[Logger] = None
396+
self._cache_dir: Optional[str] = None
396397

397398
def set_bot(self, bot: Wechaty) -> None:
398399
"""set bot instance to WechatyPlugin
@@ -432,6 +433,19 @@ def cache_dir(self) -> str:
432433
os.makedirs(_cache_dir, exist_ok=True)
433434
return _cache_dir
434435

436+
@cache_dir.setter
437+
def cache_dir(self, value: str) -> None:
438+
"""set the cache dir although there is already set
439+
440+
Args:
441+
value (str): the new cache dir
442+
"""
443+
if not self._cache_dir:
444+
self.logger.warning(f'there is already cache_dir<{self._cache_dir}>')
445+
446+
os.makedirs(value, exist_ok=True)
447+
self._cache_dir = value
448+
435449
@property
436450
def logger(self) -> Logger:
437451
"""get the default logger of plugin which will automaticly

0 commit comments

Comments
 (0)