删除Partial缓存时,同时删除区间范围相关文件

This commit is contained in:
刘祥超
2022-03-04 11:51:59 +08:00
parent 581a3d49fc
commit 269e33b9a0
10 changed files with 85 additions and 64 deletions

View File

@@ -7,7 +7,6 @@ import (
"github.com/iwind/TeaGo/types"
"io"
"os"
"strings"
)
type PartialFileReader struct {
@@ -18,19 +17,9 @@ type PartialFileReader struct {
}
func NewPartialFileReader(fp *os.File) *PartialFileReader {
// range path
var path = fp.Name()
var dotIndex = strings.LastIndex(path, ".")
var rangePath = ""
if dotIndex < 0 {
rangePath = path + "@ranges.cache"
} else {
rangePath = path[:dotIndex] + "@ranges" + path[dotIndex:]
}
return &PartialFileReader{
FileReader: NewFileReader(fp),
rangePath: rangePath,
rangePath: partialRangesFilePath(fp.Name()),
}
}