[add] better error handling, [add] font selector, [add] tailwind generation
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
39
api/utils.go
39
api/utils.go
@@ -1,12 +1,8 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"os"
|
||||
|
||||
"reichard.io/bbank/database"
|
||||
"reichard.io/bbank/graph"
|
||||
@@ -90,41 +86,6 @@ func niceSeconds(input int64) (result string) {
|
||||
return
|
||||
}
|
||||
|
||||
// Reimplemented KOReader Partial MD5 Calculation
|
||||
func calculatePartialMD5(filePath string) (string, error) {
|
||||
file, err := os.Open(filePath)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
defer file.Close()
|
||||
|
||||
var step int64 = 1024
|
||||
var size int64 = 1024
|
||||
var buf bytes.Buffer
|
||||
|
||||
for i := -1; i <= 10; i++ {
|
||||
byteStep := make([]byte, size)
|
||||
|
||||
var newShift int64 = int64(i * 2)
|
||||
var newOffset int64
|
||||
if i == -1 {
|
||||
newOffset = 0
|
||||
} else {
|
||||
newOffset = step << newShift
|
||||
}
|
||||
|
||||
_, err := file.ReadAt(byteStep, newOffset)
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
buf.Write(byteStep)
|
||||
}
|
||||
|
||||
allBytes := buf.Bytes()
|
||||
return fmt.Sprintf("%x", md5.Sum(allBytes)), nil
|
||||
}
|
||||
|
||||
// Convert Database Array -> Int64 Array
|
||||
func getSVGGraphData(inputData []database.GetDailyReadStatsRow, svgWidth int, svgHeight int) graph.SVGGraphData {
|
||||
var intData []int64
|
||||
|
||||
Reference in New Issue
Block a user