mirror of
https://github.com/openziti/zrok.git
synced 2025-06-19 17:27:54 +02:00
remove 'checksum' support until next phase (#438)
This commit is contained in:
parent
094d22872a
commit
a975b69541
@ -6,10 +6,7 @@ package webdav
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/sha512"
|
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -67,21 +64,12 @@ type webdavFile struct {
|
|||||||
|
|
||||||
func (f *webdavFile) DeadProps() (map[xml.Name]Property, error) {
|
func (f *webdavFile) DeadProps() (map[xml.Name]Property, error) {
|
||||||
var (
|
var (
|
||||||
xmlName xml.Name
|
xmlName xml.Name
|
||||||
property Property
|
property Property
|
||||||
properties = make(map[xml.Name]Property)
|
properties = make(map[xml.Name]Property)
|
||||||
checksum, err = f.checksum()
|
|
||||||
)
|
)
|
||||||
if err == nil {
|
|
||||||
xmlName.Space = "zrok:"
|
|
||||||
xmlName.Local = "checksum"
|
|
||||||
property.XMLName = xmlName
|
|
||||||
property.InnerXML = []byte(checksum)
|
|
||||||
properties[xmlName] = property
|
|
||||||
}
|
|
||||||
|
|
||||||
var stat fs.FileInfo
|
var stat fs.FileInfo
|
||||||
stat, err = f.Stat()
|
stat, err := f.Stat()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
xmlName.Space = "zrok:"
|
xmlName.Space = "zrok:"
|
||||||
xmlName.Local = "lastmodified"
|
xmlName.Local = "lastmodified"
|
||||||
@ -112,21 +100,6 @@ func (f *webdavFile) Patch(patches []Proppatch) ([]Propstat, error) {
|
|||||||
return []Propstat{stat}, nil
|
return []Propstat{stat}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *webdavFile) checksum() (string, error) {
|
|
||||||
file, err := os.Open(f.name)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
defer file.Close()
|
|
||||||
hash := sha512.New()
|
|
||||||
if _, err := io.Copy(hash, file); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
sha512 := fmt.Sprintf("%x", hash.Sum(nil))
|
|
||||||
logrus.Infof("%v = %v", f.name, sha512)
|
|
||||||
return sha512, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *webdavFile) updateModtime(path string, modtime time.Time) error {
|
func (f *webdavFile) updateModtime(path string, modtime time.Time) error {
|
||||||
if err := os.Chtimes(f.name, time.Now(), modtime); err != nil {
|
if err := os.Chtimes(f.name, time.Now(), modtime); err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user