alexhua / Aria2-Explorer

An aria2 download task management extension for chromium based browser
https://www.aria2e.com/
BSD 3-Clause "New" or "Revised" License
783 stars 66 forks source link

自动捕获导致其他扩展下载时丢失文件名 Auto capture conflict with other extension that uses chrome.downloads.download (filename missing) #114

Open fireattack opened 1 year ago

fireattack commented 1 year ago

Describe the bug When auto capture is enabled, Aria2 for Chrome causes other extensions that download file to lose their assigned filename. I experienced it in the extension rajiko, but there could be others.

To Reproduce Steps to reproduce the behavior:

  1. Enable Enable auto capture when download file size .. option. Size limit does not matter.
  2. Install this extension: https://chrome.google.com/webstore/detail/rajiko/ejcfdikabeebbgbopoagpabbdokepnff
  3. Open this https://radiko.jp/#!/ts/QRR/20230101220000
  4. Click rajiko's icon, then click "Download Timeshift"

Expected behavior The downloaded file should be named QRR_20230101233000_20230102000000.aac.

Observed behavior But when auto capture is enabled, the filename becomes eddb6791-7878-434e-87cb-452fa933304f.aac or some other UUID-like random filename.

Desktop (please complete the following information):

Additional context

rajiko uses chrome.downloads.download() to download the file, and it supplies a proper filename:

https://github.com/jackyzy823/rajiko/blob/e2600c3397c1e93c465b46666878d21554a5614a/background.js#L694-L696

However once auto capture is enabled in Aria2 for Chrome, even when the file isn't actually captured (blacklist, too small, etc.), the filename is not actually used in download for some reason.

alexhua commented 1 year ago

This a legacy bug from Chrome. Just wait for a workaround or Chrome bug fix, please.

alexhua commented 1 year ago

After a investigation, we found maybe there is no solution or workaround to deal with this conflict. The only method is turning off the auto-capture function at this situation which is caused by the defect of Chrome extension API.

fireattack commented 1 year ago

Thanks for the investigation. Would you mind to elaborate the bug, so I can report it to Chrome team?

alexhua commented 1 year ago

Thanks for the investigation. Would you mind to elaborate the bug, so I can report it to Chrome team?

You can refer to this Zhihu article https://zhuanlan.zhihu.com/p/432549456, which summarized the whole detail. And I also gave a comment below.

The key point is that when extension uses onDeterminingFilename API, Chrome pass in a original filename of DownloadItem object which is not the one set by download API from other extension.

alexhua commented 1 year ago

PS: We must use onDeterminingFilename API to capture the Chrome download task