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
// 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.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=

View File

@ -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")