From a734b3b53206e46cd1c6d62183abc5f892acdc37 Mon Sep 17 00:00:00 2001 From: Conrad Hoffmann Date: Tue, 17 May 2022 15:28:09 +0200 Subject: [PATCH] Set content length propery for DAV objects This makes collections play nice with clients that require it, like cadaver. --- go.mod | 2 +- go.sum | 4 ++-- storage/filesystem.go | 36 ++++++++++++++++++++---------------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/go.mod b/go.mod index 185fc20..dc3300f 100644 --- a/go.mod +++ b/go.mod @@ -14,4 +14,4 @@ require ( require golang.org/x/text v0.3.7 // indirect // 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 diff --git a/go.sum b/go.sum index ef1e466..39dc0a9 100644 --- a/go.sum +++ b/go.sum @@ -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.20220513133554-bf9c9fcc431a/go.mod h1:uSM1VveeKtogBVWaYccTksToczooJ0rrVGNsgnDsr4Q= +github.com/bitfehler/go-webdav v0.3.2-0.20220517131716-4ba36d52ba63 h1:MnTO1320Uc4TslRsu4qs5y855qT/QwbJMQjP7qIUFBY= +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/go.mod h1:4xVTBPcT43a1pp3vdaa+FuRdX5XhKCZPpWv7m0z9ByM= github.com/emersion/go-imap v1.2.0 h1:lyUQ3+EVM21/qbWE/4Ya5UG9r5+usDxlg4yfp3TgHFA= diff --git a/storage/filesystem.go b/storage/filesystem.go index 29fc6ba..cd19f4d 100644 --- a/storage/filesystem.go +++ b/storage/filesystem.go @@ -295,10 +295,11 @@ func (b *filesystemBackend) GetAddressObject(ctx context.Context, objPath string } obj := carddav.AddressObject{ - Path: objPath, - ModTime: info.ModTime(), - ETag: etag, - Card: card, + Path: objPath, + ModTime: info.ModTime(), + ContentLength: info.Size(), + ETag: etag, + Card: card, } return &obj, nil } @@ -332,10 +333,11 @@ func (b *filesystemBackend) loadAllContacts(ctx context.Context, propFilter []st } obj := carddav.AddressObject{ - Path: path.Join(homeSetPath, filepath.Base(filename)), - ModTime: info.ModTime(), - ETag: etag, - Card: card, + Path: path.Join(homeSetPath, filepath.Base(filename)), + ModTime: info.ModTime(), + ContentLength: info.Size(), + ETag: etag, + Card: card, } result = append(result, obj) return nil @@ -376,10 +378,11 @@ func (b *filesystemBackend) loadAllCalendars(ctx context.Context, propFilter []s } obj := caldav.CalendarObject{ - Path: path.Join(homeSetPath, filepath.Base(filename)), - ModTime: info.ModTime(), - ETag: etag, - Data: cal, + Path: path.Join(homeSetPath, filepath.Base(filename)), + ModTime: info.ModTime(), + ContentLength: info.Size(), + ETag: etag, + Data: cal, } result = append(result, obj) return nil @@ -548,10 +551,11 @@ func (b *filesystemBackend) GetCalendarObject(ctx context.Context, objPath strin } obj := caldav.CalendarObject{ - Path: objPath, - ModTime: info.ModTime(), - ETag: etag, - Data: calendar, + Path: objPath, + ModTime: info.ModTime(), + ContentLength: info.Size(), + ETag: etag, + Data: calendar, } return &obj, nil return nil, fmt.Errorf("not implemented")