Set content length propery for DAV objects

This makes collections play nice with clients that require it, like
cadaver.
This commit is contained in:
Conrad Hoffmann 2022-05-17 15:28:09 +02:00
parent 5a6306bd83
commit a734b3b532
3 changed files with 23 additions and 19 deletions

2
go.mod
View File

@ -14,4 +14,4 @@ require (
require golang.org/x/text v0.3.7 // indirect require golang.org/x/text v0.3.7 // indirect
// This needs to be removed once everything is merged upstream // This needs to be removed once everything is merged upstream
replace github.com/emersion/go-webdav v0.3.2-0.20220310154811-85d2b222bbcd => github.com/bitfehler/go-webdav v0.3.2-0.20220513133554-bf9c9fcc431a replace github.com/emersion/go-webdav v0.3.2-0.20220310154811-85d2b222bbcd => github.com/bitfehler/go-webdav v0.3.2-0.20220517131716-4ba36d52ba63

4
go.sum
View File

@ -1,5 +1,5 @@
github.com/bitfehler/go-webdav v0.3.2-0.20220513133554-bf9c9fcc431a h1:XYSxbKDn3WoYt1M3fT4RXMtzOieaNxvNs9qBxcOw6Vg= github.com/bitfehler/go-webdav v0.3.2-0.20220517131716-4ba36d52ba63 h1:MnTO1320Uc4TslRsu4qs5y855qT/QwbJMQjP7qIUFBY=
github.com/bitfehler/go-webdav v0.3.2-0.20220513133554-bf9c9fcc431a/go.mod h1:uSM1VveeKtogBVWaYccTksToczooJ0rrVGNsgnDsr4Q= github.com/bitfehler/go-webdav v0.3.2-0.20220517131716-4ba36d52ba63/go.mod h1:uSM1VveeKtogBVWaYccTksToczooJ0rrVGNsgnDsr4Q=
github.com/emersion/go-ical v0.0.0-20200224201310-cd514449c39e h1:YGM1sI7edZOt8KAfX9Miq/X99d2QXdgjkJ7vN4HjxAA= github.com/emersion/go-ical v0.0.0-20200224201310-cd514449c39e h1:YGM1sI7edZOt8KAfX9Miq/X99d2QXdgjkJ7vN4HjxAA=
github.com/emersion/go-ical v0.0.0-20200224201310-cd514449c39e/go.mod h1:4xVTBPcT43a1pp3vdaa+FuRdX5XhKCZPpWv7m0z9ByM= github.com/emersion/go-ical v0.0.0-20200224201310-cd514449c39e/go.mod h1:4xVTBPcT43a1pp3vdaa+FuRdX5XhKCZPpWv7m0z9ByM=
github.com/emersion/go-imap v1.2.0 h1:lyUQ3+EVM21/qbWE/4Ya5UG9r5+usDxlg4yfp3TgHFA= github.com/emersion/go-imap v1.2.0 h1:lyUQ3+EVM21/qbWE/4Ya5UG9r5+usDxlg4yfp3TgHFA=

View File

@ -295,10 +295,11 @@ func (b *filesystemBackend) GetAddressObject(ctx context.Context, objPath string
} }
obj := carddav.AddressObject{ obj := carddav.AddressObject{
Path: objPath, Path: objPath,
ModTime: info.ModTime(), ModTime: info.ModTime(),
ETag: etag, ContentLength: info.Size(),
Card: card, ETag: etag,
Card: card,
} }
return &obj, nil return &obj, nil
} }
@ -332,10 +333,11 @@ func (b *filesystemBackend) loadAllContacts(ctx context.Context, propFilter []st
} }
obj := carddav.AddressObject{ obj := carddav.AddressObject{
Path: path.Join(homeSetPath, filepath.Base(filename)), Path: path.Join(homeSetPath, filepath.Base(filename)),
ModTime: info.ModTime(), ModTime: info.ModTime(),
ETag: etag, ContentLength: info.Size(),
Card: card, ETag: etag,
Card: card,
} }
result = append(result, obj) result = append(result, obj)
return nil return nil
@ -376,10 +378,11 @@ func (b *filesystemBackend) loadAllCalendars(ctx context.Context, propFilter []s
} }
obj := caldav.CalendarObject{ obj := caldav.CalendarObject{
Path: path.Join(homeSetPath, filepath.Base(filename)), Path: path.Join(homeSetPath, filepath.Base(filename)),
ModTime: info.ModTime(), ModTime: info.ModTime(),
ETag: etag, ContentLength: info.Size(),
Data: cal, ETag: etag,
Data: cal,
} }
result = append(result, obj) result = append(result, obj)
return nil return nil
@ -548,10 +551,11 @@ func (b *filesystemBackend) GetCalendarObject(ctx context.Context, objPath strin
} }
obj := caldav.CalendarObject{ obj := caldav.CalendarObject{
Path: objPath, Path: objPath,
ModTime: info.ModTime(), ModTime: info.ModTime(),
ETag: etag, ContentLength: info.Size(),
Data: calendar, ETag: etag,
Data: calendar,
} }
return &obj, nil return &obj, nil
return nil, fmt.Errorf("not implemented") return nil, fmt.Errorf("not implemented")