diff --git a/chunk.go b/chunk.go index 6bde9a7..be01765 100644 --- a/chunk.go +++ b/chunk.go @@ -214,13 +214,14 @@ func Chunk(ctx context.Context, var seekEnd int64 = seekStart + firstCut - 1 log.Infof("first cut %d, seek start at %d, end at %d", firstCut, seekStart, seekEnd) log.Infof("----------------") - graphFiles = append(graphFiles, Finfo{ + fi := Finfo{ Path: item.Path, Name: fmt.Sprintf("%s.%08d", item.Info.Name(), fileSliceCount), Info: item.Info, SeekStart: seekStart, SeekEnd: seekEnd, - }) + } + graphFiles = append(graphFiles, tryRenameFileName([]Finfo{fi})...) fileSliceCount++ // todo build ipld from graphFiles BuildIpldGraph(ctx, append(ef.getFiles(), graphFiles...), GenGraphName(graphName, graphSliceCount, sliceTotal), parentPath, carDir, parallel, cb, expectSliceSize, ef) @@ -239,13 +240,14 @@ func Chunk(ctx context.Context, log.Infof("following cut %d, seek start at %d, end at %d", seekEnd-seekStart+1, seekStart, seekEnd) log.Infof("----------------") cumuSize += seekEnd - seekStart + 1 - graphFiles = append(graphFiles, Finfo{ + fi := Finfo{ Path: item.Path, Name: fmt.Sprintf("%s.%08d", item.Info.Name(), fileSliceCount), Info: item.Info, SeekStart: seekStart, SeekEnd: seekEnd, - }) + } + graphFiles = append(graphFiles, tryRenameFileName([]Finfo{fi})...) fileSliceCount++ if seekEnd-seekStart == partSliceSize-1 { // todo build ipld from graphFiles diff --git a/utils.go b/utils.go index 422601f..687073e 100644 --- a/utils.go +++ b/utils.go @@ -598,16 +598,25 @@ func tryRenameFileName(fis []Finfo) []Finfo { return in } // 重新拼接文件名 - return fmt.Sprintf("%s_%s.%s", parts[0], RandomLetters(), arr[1]) + return fmt.Sprintf("%s_%s.%s", parts[0], RandomLetters(), strings.Join(arr[1:], ".")) } for i, fi := range fis { - // log.Infof("try rename file: %s", fi.Name) + log.Infof("try rename file: %s", fi.Name) if nameReg.MatchString(fi.Name) { newName := rename(fi.Name) fis[i].Name = newName // log.Infof("rename file name %s to %s", fi.Name, newName) } + // graphsplit_sss.png.00000001 + arr := strings.Split(fi.Name, ".") + if len(arr) == 3 { + if nameReg.MatchString(arr[0] + "." + arr[1]) { + newName := rename(fi.Name) + fis[i].Name = newName + // log.Infof("rename file name %s to %s", fi.Name, newName) + } + } } return fis