From 75c511a49f0f618f1c155625df9d1b314530c152 Mon Sep 17 00:00:00 2001 From: qydysky Date: Tue, 28 Nov 2023 23:58:26 +0800 Subject: [PATCH] =?utf8?q?Improve=20=E7=A7=BB=E9=99=A4=E5=8E=86=E5=8F=B2?= =?utf8?q?=E6=B5=81=E6=94=B6=E6=95=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Reply/stream.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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()) } } } -- 2.39.2