()
| 4 | import { rclone_api_post } from '../../utils/rclone/request' |
| 5 | |
| 6 | async function reupStats() { |
| 7 | const stats = (await rclone_api_post('/core/stats')) as RcloneStats | undefined |
| 8 | |
| 9 | if (!stats) { |
| 10 | return |
| 11 | } |
| 12 | |
| 13 | let realSpeed: number = 0 |
| 14 | |
| 15 | if (stats.transferring && stats.transferring.length > 0) { |
| 16 | stats.transferring.forEach((item: RcloneTransferItem) => { |
| 17 | realSpeed += item.speed |
| 18 | }) |
| 19 | } |
| 20 | |
| 21 | rcloneInfo.stats = { |
| 22 | ...stats, |
| 23 | realSpeed: realSpeed || 0 /* stats.speed */, |
| 24 | } |
| 25 | |
| 26 | //历史状态 |
| 27 | rcloneStatsHistory.push(stats) |
| 28 | |
| 29 | if (rcloneStatsHistory.length > 32) { |
| 30 | rcloneStatsHistory.splice(0, rcloneStatsHistory.length - 32) |
| 31 | } |
| 32 | |
| 33 | hooks.upStats() |
| 34 | } |
| 35 | |
| 36 | export { reupStats } |
no test coverage detected