fix(资产管理): 素材根目录不存在时仍列出账号库
生产只同步了账号库、没有搬素材时 data/accounts 不存在, list_accounts 提前 return [] 导致资产页一个账号都不显示。 根目录缺失按空目录处理,继续并入账号库;补回归用例。
This commit is contained in:
@@ -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)))
|
||||
|
||||
Reference in New Issue
Block a user