Merge branch 'dev' —— 修复资产管理在无素材目录时不显示账号

This commit is contained in:
2026-10-18 14:12:28 +08:00
2 changed files with 19 additions and 2 deletions
+4 -2
View File
@@ -131,10 +131,12 @@ def list_accounts(prof=None):
try:
names = sorted(os.listdir(root))
except FileNotFoundError:
return []
# 素材根目录还不存在(例如生产只同步了账号库、没搬素材)——
# 账号库仍要能列出来,不能在这里提前返回。
names = []
except Exception as e:
_log.warning("列账号目录失败(%s): %s", root, e)
return []
names = []
exts = _media_exts(prof)
with _ctx():
# **账号来源 = 素材目录 ∪ 账号库**:账号库里登记了但还没建文件夹的号也要看得见
+15
View File
@@ -281,6 +281,21 @@ with app.app_context():
check('素材文件夹归档了(原文件还在)',
bool(_arch) and os.path.isfile(os.path.join(ROOT, _arch, 'a.mp4')), True)
print('=== 11. 素材根目录不存在时,账号库仍要列出来 ===')
with app.app_context():
db.session.add(DeviceAccount(id='noroot1', device_name='A99',
nickname='只登记没目录', douyin_id='888',
created_at='2026-10-18'))
db.session.commit()
_missing = os.path.join(ROOT, '这个目录不存在')
_rows = af.list_accounts({'source': {'root': _missing}})
check('根目录缺失也能列出账号库的号',
[r['name'] for r in _rows if r['name'] == '只登记没目录'],
['只登记没目录'])
_hit = [r for r in _rows if r['name'] == '只登记没目录'][0]
check('没有目录的号 has_dir=False', _hit['has_dir'], False)
check('所属手机来自账号库', _hit['device_name'], 'A99')
print()
if fails:
print('❌ 失败 %d 项:%s' % (len(fails), ' / '.join(fails)))