feat: option to change file hash when update to webdav

This commit is contained in:
Simon Ding
2024-07-23 15:18:42 +08:00
parent 8d2ce9752b
commit 6826422c2b
6 changed files with 50 additions and 11 deletions

View File

@@ -1,6 +1,7 @@
package utils
import (
"os"
"regexp"
"strconv"
"strings"
@@ -146,3 +147,16 @@ func AvailableSpace(dir string) uint64 {
unix.Statfs(dir, &stat)
return stat.Bavail * uint64(stat.Bsize)
}
func ChangeFileHash(name string) error {
f, err := os.OpenFile(name, os.O_APPEND|os.O_WRONLY, 0655)
if err != nil {
return errors.Wrap(err, "open file")
}
defer f.Close()
_, err = f.Write([]byte("\000"))
if err != nil {
return errors.Wrap(err, "write file")
}
return nil
}