mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-22 16:24:14 +00:00
carddav: add Stat to AddressObject interface
This commit is contained in:
parent
163fa1656d
commit
7d69432517
@ -4,6 +4,7 @@ package carddav
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
|
||||
"github.com/emersion/go-vcard"
|
||||
)
|
||||
@ -15,6 +16,7 @@ var (
|
||||
type AddressObject interface {
|
||||
ID() string
|
||||
Card() (vcard.Card, error)
|
||||
Stat() (os.FileInfo, error) // can return nil, nil
|
||||
}
|
||||
|
||||
type AddressBook interface {
|
||||
|
@ -117,6 +117,11 @@ func (f *file) Readdir(count int) ([]os.FileInfo, error) {
|
||||
}
|
||||
|
||||
func (f *file) Stat() (os.FileInfo, error) {
|
||||
info, err := f.ao.Stat()
|
||||
if info != nil || err != nil {
|
||||
return info, err
|
||||
}
|
||||
|
||||
return &fileInfo{
|
||||
name: f.name,
|
||||
mode: os.ModePerm,
|
||||
@ -158,10 +163,18 @@ func (d *dir) Readdir(count int) ([]os.FileInfo, error) {
|
||||
|
||||
d.files = make([]os.FileInfo, len(aos))
|
||||
for i, ao := range aos {
|
||||
d.files[i] = &fileInfo{
|
||||
f := &file{
|
||||
fs: d.fs,
|
||||
name: ao.ID() + ".vcf",
|
||||
mode: os.ModePerm,
|
||||
ao: ao,
|
||||
}
|
||||
|
||||
info, err := f.Stat()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
d.files[i] = info
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user