From: qydysky Date: Tue, 28 Nov 2023 15:58:26 +0000 (+0800) Subject: Improve 移除历史流收敛 X-Git-Tag: v0.11.8~3 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=75c511a49f0f618f1c155625df9d1b314530c152;p=bili_danmu%2F.git Improve 移除历史流收敛 --- diff --git a/Reply/stream.go b/Reply/stream.go index 5868109..4b44c06 100644 --- a/Reply/stream.go +++ b/Reply/stream.go @@ -543,22 +543,22 @@ func (t *M4SStream) removeStream() (e error) { var ( oldest float64 - oldIndex int = -1 + oldIndex []int ) for i, n := 0, len(list); i < n; i++ { if list[i].IsDir() && len(list[i].Name()) > 20 { if tt, err := time.Parse("2006_01_02-15_04_05", list[i].Name()[:19]); err == nil { if ts := time.Since(tt).Seconds(); ts > d*24*60*60 && ts > oldest { oldest = ts - oldIndex = i + oldIndex = append(oldIndex, i) } } } } - if oldIndex != -1 { - t.log.L(`I: `, "移除历史流", v+"/"+list[oldIndex].Name()) - return os.RemoveAll(v + "/" + list[oldIndex].Name()) + for n, i := 2, len(oldIndex)-1; n > 0 && i >= 0; n, i = n-1, i-1 { + t.log.L(`I: `, "移除历史流", v+"/"+list[oldIndex[i]].Name()) + os.RemoveAll(v + "/" + list[oldIndex[i]].Name()) } } }