add small clean up method

This commit is contained in:
2025-04-23 08:06:03 +02:00
parent ba8a9023ea
commit 494d26c712
3 changed files with 63 additions and 3 deletions

View File

@@ -171,7 +171,7 @@ func (s *server) GenerateThumbnail(ctx context.Context, req *pb.ThumbnailRequest
if _, err := os.Stat(outputPath); err == nil {
os.Remove(outputPath)
}
end := time.Since(time.Now())
end := time.Since(start)
fmt.Println(time.Now().Format("2006-01-02 15:04:05.000"), "Finshed in: ", end, req.FileType, "H: ", req.MaxHeight, "W: ", req.MaxWidth)
}()
@@ -191,7 +191,7 @@ func (s *server) OcrFile(ctx context.Context, req *pb.OCRFileRequest) (*pb.OCRFi
fmt.Println(start.Format("2006-01-02 15:04:05.000"), "OCR request ", req.FileType)
defer func() {
end := time.Since(time.Now())
end := time.Since(start)
fmt.Println(time.Now().Format("2006-01-02 15:04:05.000"), "OCR Finshed in: ", end, req.FileType)
}()
@@ -239,6 +239,10 @@ func (s *server) OcrFile(ctx context.Context, req *pb.OCRFileRequest) (*pb.OCRFi
return handleErr("failed to extract text", err)
}
if req.CleanUp {
text = cleanOCRText(text)
}
return &pb.OCRFileResponse{
Message: "OCR success",
TextContent: text,