Remove tmp files on start up
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -123,6 +124,20 @@ func FormatWALFilename(index int) string {
|
||||
return fmt.Sprintf("%016x%s", index, WALExt)
|
||||
}
|
||||
|
||||
// removeTmpFiles recursively finds and removes .tmp files.
|
||||
func removeTmpFiles(root string) error {
|
||||
return filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return nil // skip errored files
|
||||
} else if info.IsDir() {
|
||||
return nil // skip directories
|
||||
} else if !strings.HasSuffix(path, ".tmp") {
|
||||
return nil // skip non-temp files
|
||||
}
|
||||
return os.Remove(path)
|
||||
})
|
||||
}
|
||||
|
||||
// HexDump returns hexdump output but with duplicate lines removed.
|
||||
func HexDump(b []byte) string {
|
||||
const prefixN = len("00000000")
|
||||
|
||||
Reference in New Issue
Block a user