File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 2525from .utils import LoguruHandler , StreamToLogger , coroutine , get_subclasses
2626
2727require ("nonebot_plugin_localstore" )
28- from nonebot_plugin_localstore import get_data_dir
28+ from nonebot_plugin_localstore import get_data_dir , get_plugin_data_dir
2929
3030__all__ = (
3131 # __init__
6060_session_factory : sa_async .async_sessionmaker [sa_async .AsyncSession ]
6161_scoped_sessions : sa_async .async_scoped_session [sa_async .AsyncSession ]
6262
63- _data_dir = get_data_dir ("nonebot_plugin_orm" )
64- if (_deprecated_data_dir := get_data_dir (None ) / "nonebot-plugin-orm" ).exists ():
63+ _data_dir = get_plugin_data_dir ()
64+ if (
65+ _deprecated_data_dir := get_data_dir (None ) / "nonebot-plugin-orm"
66+ ).exists () and next (_deprecated_data_dir .iterdir (), None ):
67+ if next (_data_dir .iterdir (), None ):
68+ raise RuntimeError (
69+ "无法自动迁移数据目录, 请手动将 "
70+ f"{ _deprecated_data_dir } 中的数据移动到 { _data_dir } 中."
71+ )
72+ _data_dir .rmdir ()
6573 _deprecated_data_dir .rename (_data_dir )
6674
6775_driver = get_driver ()
You can’t perform that action at this time.
0 commit comments