Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: duplicate danmaku filename when fallback #190

Merged
merged 1 commit into from
Mar 5, 2025
Merged

fix: duplicate danmaku filename when fallback #190

merged 1 commit into from
Mar 5, 2025

Conversation

Tony15246
Copy link
Owner

由于不只是电影电视剧,正常的从源添加弹幕有时也会回落到get_danmaku_fallback函数。而由于get_danmaku_fallback设置的弹幕文件名的重复,会导致新fallback到get_danmaku_fallback函数获取的弹幕,会覆盖之前别的fallback的弹幕源的弹幕。因此添加了count作为唯一标识,避免弹幕文件名重复。

@Tony15246 Tony15246 requested a review from dyphire March 5, 2025 07:52
@dyphire
Copy link
Collaborator

dyphire commented Mar 5, 2025

删除文件那里是不是也要改下

@Tony15246
Copy link
Owner Author

删除文件那里是不是也要改下

这个倒是不需要,删除文件那里是遍历所有弹幕源对应的弹幕文件进行删除的,不会有遗漏的

uosc_danmaku/render.lua

Lines 382 to 386 in 7ed245a

for _, source in pairs(danmaku.sources) do
if source.fname and source.from and source.from ~= "user_local" and file_exists(source.fname) then
os.remove(source.fname)
end
end

@dyphire
Copy link
Collaborator

dyphire commented Mar 5, 2025

删除文件那里是不是也要改下

这个倒是不需要,删除文件那里是遍历所有弹幕源对应的弹幕文件进行删除的,不会有遗漏的

uosc_danmaku/render.lua

Lines 382 to 386 in 7ed245a

for _, source in pairs(danmaku.sources) do
if source.fname and source.from and source.from ~= "user_local" and file_exists(source.fname) then
os.remove(source.fname)
end
end

OK,那原来的 rm 逻辑是不是可以清理下,比如 rm3 应该不需要了

@Tony15246
Copy link
Owner Author

Tony15246 commented Mar 5, 2025

删除文件那里是不是也要改下

这个倒是不需要,删除文件那里是遍历所有弹幕源对应的弹幕文件进行删除的,不会有遗漏的

uosc_danmaku/render.lua

Lines 382 to 386 in 7ed245a

for _, source in pairs(danmaku.sources) do
if source.fname and source.from and source.from ~= "user_local" and file_exists(source.fname) then
os.remove(source.fname)
end
end

OK,那原来的 rm 逻辑是不是可以清理下,比如 rm3 应该不需要了

可以,那就去掉吧

这样的话其实rm3和rm5都可以去掉。这两个获取巴哈和b站弹幕的函数也重构成了调用save_danmaku_downloaded进行弹幕加载,也不需要专门删除了

不对,我犯傻了,rm5"bahamut-" .. pid .. ".json"是中间弹幕文件,不是最终加载的弹幕文件,这个不会记录在弹幕源对应的弹幕文件里,需要手动删除。那还是只有rm3可以删

@Tony15246 Tony15246 marked this pull request as draft March 5, 2025 09:10
@Tony15246
Copy link
Owner Author

Tony15246 commented Mar 5, 2025

突然发现巴哈姆特弹幕文件保存用的文件名是"danmaku-" .. pid .. ".json",和save_json_for_factory里用的默认弹幕文件名称重复了,这样的话这两个文件也有可能存在的冲突覆盖问题。之前居然一直没发现,可能用mpv在线看巴哈姆特的人不多,这个bug居然一直藏到现在。

我把这个也顺便一起改了

@Tony15246 Tony15246 marked this pull request as ready for review March 5, 2025 09:35
@Tony15246
Copy link
Owner Author

ok,改完了

Copy link
Collaborator

@dyphire dyphire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dyphire dyphire merged commit 38652a5 into main Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants