Skip to content

Commit

Permalink
chore: move to github.com/DeepDiver1975/go-webdav
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepDiver1975 committed Mar 8, 2024
1 parent 60b7da4 commit 7d52439
Show file tree
Hide file tree
Showing 36 changed files with 210 additions and 164 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.22
require (
dario.cat/mergo v1.0.0
github.com/CiscoM31/godata v1.0.10
github.com/DeepDiver1975/go-webdav v0.0.0-20240308110728-8857da010229
github.com/KimMachineGun/automemlimit v0.5.0
github.com/Masterminds/semver v1.5.0
github.com/MicahParks/keyfunc v1.9.0
Expand All @@ -21,7 +22,6 @@ require (
github.com/egirna/icap-client v0.1.1
github.com/emersion/go-ical v0.0.0-20220601085725-0864dccc089f
github.com/emersion/go-vcard v0.0.0-20230815062825-8fda7d206ec9
github.com/emersion/go-webdav v0.5.1-0.20240208161504-ad1fe1c5a88b
github.com/gabriel-vasile/mimetype v1.4.3
github.com/ggwhite/go-masker v1.1.0
github.com/go-chi/chi/v5 v5.0.12
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
github.com/CiscoM31/godata v1.0.10 h1:DZdJ6M8QNh4HquvDDOqNLu6h77Wl86KGK7Qlbmb90sk=
github.com/CiscoM31/godata v1.0.10/go.mod h1:ZMiT6JuD3Rm83HEtiTx4JEChsd25YCrxchKGag/sdTc=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/DeepDiver1975/go-webdav v0.0.0-20240308110728-8857da010229 h1:87YdHDobZHYm4tqpEX/GnidYmEupIJ02Zst/uEkFN40=
github.com/DeepDiver1975/go-webdav v0.0.0-20240308110728-8857da010229/go.mod h1:oTZKMN5qSdbmLQvbRJVcv0i2J/+w9aXQORFHNZi3XY4=
github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk=
github.com/KimMachineGun/automemlimit v0.5.0 h1:BeOe+BbJc8L5chL3OwzVYjVzyvPALdd5wxVVOWuUZmQ=
github.com/KimMachineGun/automemlimit v0.5.0/go.mod h1:di3GCKiu9Y+1fs92erCbUvKzPkNyViN3mA0vti/ykEQ=
Expand Down Expand Up @@ -1073,8 +1075,6 @@ github.com/emersion/go-ical v0.0.0-20220601085725-0864dccc089f h1:feGUUxxvOtWVOh
github.com/emersion/go-ical v0.0.0-20220601085725-0864dccc089f/go.mod h1:2MKFUgfNMULRxqZkadG1Vh44we3y5gJAtTBlVsx1BKQ=
github.com/emersion/go-vcard v0.0.0-20230815062825-8fda7d206ec9 h1:ATgqloALX6cHCranzkLb8/zjivwQ9DWWDCQRnxTPfaA=
github.com/emersion/go-vcard v0.0.0-20230815062825-8fda7d206ec9/go.mod h1:HMJKR5wlh/ziNp+sHEDV2ltblO4JD2+IdDOWtGcQBTM=
github.com/emersion/go-webdav v0.5.1-0.20240208161504-ad1fe1c5a88b h1:odkjfh9GaV3KHJB5uBto9g63+mJtOL9qgdHFawYA0tY=
github.com/emersion/go-webdav v0.5.1-0.20240208161504-ad1fe1c5a88b/go.mod h1:ycyIzTelG5pHln4t+Y32/zBvmrM7+mV7x+V+Gx4ZQno=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/emvi/iso-639-1 v1.1.0 h1:EhZiYVA+ysa/b7+0T2DD9hcX7E/5sh4o1KyDAIPu7VE=
Expand Down
2 changes: 1 addition & 1 deletion services/ccs/pkg/command/create_addressbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package command
import (
"context"
"fmt"
"github.com/DeepDiver1975/go-webdav/carddav"
userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
revaContext "github.com/cs3org/reva/v2/pkg/ctx"
"github.com/emersion/go-webdav/carddav"
config2 "github.com/owncloud/ocis/v2/ocis-pkg/config"
parser2 "github.com/owncloud/ocis/v2/ocis-pkg/config/parser"
ogrpc "github.com/owncloud/ocis/v2/ocis-pkg/service/grpc"
Expand Down
2 changes: 1 addition & 1 deletion services/ccs/pkg/command/create_calendar.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package command
import (
"context"
"fmt"
"github.com/DeepDiver1975/go-webdav/caldav"
userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
revaContext "github.com/cs3org/reva/v2/pkg/ctx"
"github.com/emersion/go-webdav/caldav"
config2 "github.com/owncloud/ocis/v2/ocis-pkg/config"
parser2 "github.com/owncloud/ocis/v2/ocis-pkg/config/parser"
ogrpc "github.com/owncloud/ocis/v2/ocis-pkg/service/grpc"
Expand Down
52 changes: 21 additions & 31 deletions services/ccs/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
)

type Storage struct {
GatewayAddress string `yaml:"gateway_addr" env:"STORAGE_GATEWAY_GRPC_ADDR" desc:"GRPC address of the STORAGE-SYSTEM service."`
GatewayAddress string `yaml:"gateway_addr" env:"STORAGE_GATEWAY_GRPC_ADDR" desc:"GRPC address of the STORAGE-SYSTEM service." introductionVersion:"5.0"`

SystemUserID string `yaml:"system_user_id" env:"OCIS_SYSTEM_USER_ID;CCS_SYSTEM_USER_ID" desc:"ID of the oCIS STORAGE-SYSTEM system user. Admins need to set the ID for the STORAGE-SYSTEM system user in this config option which is then used to reference the user. Any reasonable long string is possible, preferably this would be an UUIDv4 format."`
SystemUserIDP string `yaml:"system_user_idp" env:"OCIS_SYSTEM_USER_IDP;CCS_SYSTEM_USER_IDP" desc:"IDP of the oCIS STORAGE-SYSTEM system user."`
SystemUserAPIKey string `yaml:"system_user_api_key" env:"OCIS_SYSTEM_USER_API_KEY" desc:"API key for the STORAGE-SYSTEM system user."`
SystemUserID string `yaml:"system_user_id" env:"OCIS_SYSTEM_USER_ID;CCS_SYSTEM_USER_ID" desc:"ID of the oCIS STORAGE-SYSTEM system user. Admins need to set the ID for the STORAGE-SYSTEM system user in this config option which is then used to reference the user. Any reasonable long string is possible, preferably this would be an UUIDv4 format." introductionVersion:"5.0"`
SystemUserIDP string `yaml:"system_user_idp" env:"OCIS_SYSTEM_USER_IDP;CCS_SYSTEM_USER_IDP" desc:"IDP of the oCIS STORAGE-SYSTEM system user." introductionVersion:"5.0"`
SystemUserAPIKey string `yaml:"system_user_api_key" env:"OCIS_SYSTEM_USER_API_KEY" desc:"API key for the STORAGE-SYSTEM system user." introductionVersion:"5.0"`
}

type Config struct {
Expand All @@ -25,51 +25,41 @@ type Config struct {
HTTP HTTPConfig `yaml:"http"`

Context context.Context `yaml:"-"`
JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET;CCS_JWT_SECRET" desc:"The secret to mint and validate jwt tokens."`
JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET;CCS_JWT_SECRET" desc:"The secret to mint and validate jwt tokens." introductionVersion:"5.0"`
}

type Log struct {
Level string `yaml:"level" env:"OCIS_LOG_LEVEL;CCS_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'."`
Pretty bool `yaml:"pretty" env:"OCIS_LOG_PRETTY;CCS_LOG_PRETTY" desc:"Activates pretty log output."`
Color bool `yaml:"color" env:"OCIS_LOG_COLOR;CCS_LOG_COLOR" desc:"Activates colorized log output."`
File string `yaml:"file" env:"OCIS_LOG_FILE;CCS_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set."`
Level string `yaml:"level" env:"OCIS_LOG_LEVEL;CCS_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'." introductionVersion:"5.0"`
Pretty bool `yaml:"pretty" env:"OCIS_LOG_PRETTY;CCS_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"5.0"`
Color bool `yaml:"color" env:"OCIS_LOG_COLOR;CCS_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"5.0"`
File string `yaml:"file" env:"OCIS_LOG_FILE;CCS_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"5.0"`
}

type Service struct {
Name string `yaml:"-"`
}

type Debug struct {
Addr string `yaml:"addr" env:"CCS_DEBUG_ADDR" desc:"Bind address of the debug server, where metrics, health, config and debug endpoints will be exposed."`
Token string `yaml:"token" env:"CCS_DEBUG_TOKEN" desc:"Token to secure the metrics endpoint."`
Pprof bool `yaml:"pprof" env:"CCS_DEBUG_PPROF" desc:"Enables pprof, which can be used for profiling."`
Zpages bool `yaml:"zpages" env:"CCS_DEBUG_ZPAGES" desc:"Enables zpages, which can be used for collecting and viewing in-memory traces."`
Addr string `yaml:"addr" env:"CCS_DEBUG_ADDR" desc:"Bind address of the debug server, where metrics, health, config and debug endpoints will be exposed." introductionVersion:"5.0"`
Token string `yaml:"token" env:"CCS_DEBUG_TOKEN" desc:"Token to secure the metrics endpoint." introductionVersion:"5.0"`
Pprof bool `yaml:"pprof" env:"CCS_DEBUG_PPROF" desc:"Enables pprof, which can be used for profiling." introductionVersion:"5.0"`
Zpages bool `yaml:"zpages" env:"CCS_DEBUG_ZPAGES" desc:"Enables zpages, which can be used for collecting and viewing in-memory traces." introductionVersion:"5.0"`
}

type HTTPConfig struct {
Addr string `yaml:"addr" env:"CCS_HTTP_ADDR" desc:"The bind address of the HTTP service."`
Addr string `yaml:"addr" env:"CCS_HTTP_ADDR" desc:"The bind address of the HTTP service." introductionVersion:"5.0"`
Namespace string `yaml:"-"`
Root string `yaml:"root" env:"CCS_HTTP_ROOT" desc:"Subdirectory that serves as the root for this HTTP service."`
Root string `yaml:"root" env:"CCS_HTTP_ROOT" desc:"Subdirectory that serves as the root for this HTTP service." introductionVersion:"5.0"`
TLS shared.HTTPServiceTLS `yaml:"tls"`
Protocol string `yaml:"protocol" env:"CCS_HTTP_PROTOCOL" desc:"The transport protocol of the HTTP service."`
Prefix string `yaml:"prefix" env:"CCS_HTTP_PREFIX" desc:"A URL path prefix for the handler."`
Protocol string `yaml:"protocol" env:"CCS_HTTP_PROTOCOL" desc:"The transport protocol of the HTTP service." introductionVersion:"5.0"`
Prefix string `yaml:"prefix" env:"CCS_HTTP_PREFIX" desc:"A URL path prefix for the handler." introductionVersion:"5.0"`
CORS `yaml:"cors"`
}

// CORS defines the available cors configuration.
type CORS struct {
AllowedOrigins []string `yaml:"allow_origins" env:"OCIS_CORS_ALLOW_ORIGINS;CCS_CORS_ALLOW_ORIGINS" desc:"A list of allowed CORS origins. See following chapter for more details: *Access-Control-Allow-Origin* at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin. See the Environment Variable Types description for more details."`
AllowedMethods []string `yaml:"allow_methods" env:"OCIS_CORS_ALLOW_METHODS;CCS_CORS_ALLOW_METHODS" desc:"A list of allowed CORS methods. See following chapter for more details: *Access-Control-Request-Method* at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Request-Method. See the Environment Variable Types description for more details."`
AllowedHeaders []string `yaml:"allow_headers" env:"OCIS_CORS_ALLOW_HEADERS;CCS_CORS_ALLOW_HEADERS" desc:"A list of allowed CORS headers. See following chapter for more details: *Access-Control-Request-Headers* at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Request-Headers. See the Environment Variable Types description for more details."`
AllowCredentials bool `yaml:"allow_credentials" env:"OCIS_CORS_ALLOW_CREDENTIALS;CCS_CORS_ALLOW_CREDENTIALS" desc:"Allow credentials for CORS.See following chapter for more details: *Access-Control-Allow-Credentials* at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials."`
}

// Status holds the configurable values for the status.php
type Status struct {
Version string
VersionString string
Product string
ProductName string
ProductVersion string
Edition string `yaml:"edition" env:"OCIS_EDITION;CCS_EDITION"`
AllowedOrigins []string `yaml:"allow_origins" env:"OCIS_CORS_ALLOW_ORIGINS;CCS_CORS_ALLOW_ORIGINS" desc:"A list of allowed CORS origins. See following chapter for more details: *Access-Control-Allow-Origin* at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin. See the Environment Variable Types description for more details." introductionVersion:"5.0"`
AllowedMethods []string `yaml:"allow_methods" env:"OCIS_CORS_ALLOW_METHODS;CCS_CORS_ALLOW_METHODS" desc:"A list of allowed CORS methods. See following chapter for more details: *Access-Control-Request-Method* at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Request-Method. See the Environment Variable Types description for more details." introductionVersion:"5.0"`
AllowedHeaders []string `yaml:"allow_headers" env:"OCIS_CORS_ALLOW_HEADERS;CCS_CORS_ALLOW_HEADERS" desc:"A list of allowed CORS headers. See following chapter for more details: *Access-Control-Request-Headers* at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Request-Headers. See the Environment Variable Types description for more details." introductionVersion:"5.0"`
AllowCredentials bool `yaml:"allow_credentials" env:"OCIS_CORS_ALLOW_CREDENTIALS;CCS_CORS_ALLOW_CREDENTIALS" desc:"Allow credentials for CORS.See following chapter for more details: *Access-Control-Allow-Credentials* at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials." introductionVersion:"5.0"`
}
8 changes: 4 additions & 4 deletions services/ccs/pkg/config/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import "github.com/owncloud/ocis/v2/ocis-pkg/tracing"

// Tracing defines the available tracing configuration.
type Tracing struct {
Enabled bool `yaml:"enabled" env:"OCIS_TRACING_ENABLED;CALDAV_TRACING_ENABLED" desc:"Activates tracing."`
Type string `yaml:"type" env:"OCIS_TRACING_TYPE;CALDAV_TRACING_TYPE" desc:"The type of tracing. Defaults to '', which is the same as 'jaeger'. Allowed tracing types are 'jaeger' and '' as of now."`
Endpoint string `yaml:"endpoint" env:"OCIS_TRACING_ENDPOINT;CALDAV_TRACING_ENDPOINT" desc:"The endpoint of the tracing agent."`
Collector string `yaml:"collector" env:"OCIS_TRACING_COLLECTOR;CALDAV_TRACING_COLLECTOR" desc:"The HTTP endpoint for sending spans directly to a collector, i.e. http://jaeger-collector:14268/api/traces. Only used if the tracing endpoint is unset."`
Enabled bool `yaml:"enabled" env:"OCIS_TRACING_ENABLED;CALDAV_TRACING_ENABLED" desc:"Activates tracing." introductionVersion:"5.0"`
Type string `yaml:"type" env:"OCIS_TRACING_TYPE;CALDAV_TRACING_TYPE" desc:"The type of tracing. Defaults to '', which is the same as 'jaeger'. Allowed tracing types are 'jaeger' and '' as of now." introductionVersion:"5.0"`
Endpoint string `yaml:"endpoint" env:"OCIS_TRACING_ENDPOINT;CALDAV_TRACING_ENDPOINT" desc:"The endpoint of the tracing agent." introductionVersion:"5.0"`
Collector string `yaml:"collector" env:"OCIS_TRACING_COLLECTOR;CALDAV_TRACING_COLLECTOR" desc:"The HTTP endpoint for sending spans directly to a collector, i.e. http://jaeger-collector:14268/api/traces. Only used if the tracing endpoint is unset." introductionVersion:"5.0"`
}

// Convert Tracing to the tracing package's Config struct.
Expand Down
6 changes: 3 additions & 3 deletions services/ccs/pkg/service/v0/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"context"
"errors"
"fmt"
"github.com/DeepDiver1975/go-webdav"
"github.com/DeepDiver1975/go-webdav/caldav"
"github.com/DeepDiver1975/go-webdav/carddav"
revaContext "github.com/cs3org/reva/v2/pkg/ctx"
"github.com/cs3org/reva/v2/pkg/storage/utils/metadata"
"github.com/emersion/go-webdav"
"github.com/emersion/go-webdav/caldav"
"github.com/emersion/go-webdav/carddav"
chi "github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
"github.com/owncloud/ocis/v2/ocis-pkg/account"
Expand Down
6 changes: 3 additions & 3 deletions services/ccs/pkg/storage/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"path/filepath"
"strings"

"github.com/emersion/go-webdav"
"github.com/emersion/go-webdav/caldav"
"github.com/emersion/go-webdav/carddav"
"github.com/DeepDiver1975/go-webdav"
"github.com/DeepDiver1975/go-webdav/caldav"
"github.com/DeepDiver1975/go-webdav/carddav"
)

type filesystemBackend struct {
Expand Down
24 changes: 14 additions & 10 deletions services/ccs/pkg/storage/filesystem_caldav.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/DeepDiver1975/go-webdav"
"github.com/DeepDiver1975/go-webdav/caldav"
providerv1beta1 "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
revaContext "github.com/cs3org/reva/v2/pkg/ctx"
"github.com/cs3org/reva/v2/pkg/storage/utils/metadata"
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/emersion/go-ical"
"github.com/emersion/go-webdav"
"github.com/emersion/go-webdav/caldav"
"github.com/rs/zerolog/log"
"net/http"
"path"
Expand Down Expand Up @@ -279,24 +279,24 @@ func (b *filesystemBackend) QueryCalendarObjects(ctx context.Context, urlPath st
return filtered, err
}

func (b *filesystemBackend) PutCalendarObject(ctx context.Context, objPath string, calendar *ical.Calendar, opts *caldav.PutCalendarObjectOptions) (loc string, err error) {
func (b *filesystemBackend) PutCalendarObject(ctx context.Context, objPath string, calendar *ical.Calendar, opts *caldav.PutCalendarObjectOptions) (*caldav.CalendarObject, error) {
log.Debug().Str("path", objPath).Msg("filesystem.PutCalendarObject()")

_, _, err = caldav.ValidateCalendarObject(calendar)
_, _, err := caldav.ValidateCalendarObject(calendar)
if err != nil {
return "", caldav.NewPreconditionError(caldav.PreconditionValidCalendarObjectResource)
return nil, caldav.NewPreconditionError(caldav.PreconditionValidCalendarObjectResource)
}

localPath, err := b.safeLocalCalDAVPath(ctx, objPath)
if err != nil {
return "", err
return nil, err
}

var buf bytes.Buffer
enc := ical.NewEncoder(&buf)
err = enc.Encode(calendar)
if err != nil {
return "", err
return nil, err
}

req := metadata.UploadRequest{
Expand All @@ -315,17 +315,21 @@ func (b *filesystemBackend) PutCalendarObject(ctx context.Context, objPath strin
} else if opts.IfMatch.IsSet() {
want, err := opts.IfMatch.ETag()
if err != nil {
return "", webdav.NewHTTPError(http.StatusBadRequest, err)
return nil, webdav.NewHTTPError(http.StatusBadRequest, err)
}
req.IfMatchEtag = want
}

_, err = b.storage.Upload(ctx, req)
if err != nil {
return "", err
return nil, err
}
calendarObject, err := b.GetCalendarObject(ctx, objPath, nil)
if err != nil {
return nil, err
}

return objPath, nil
return calendarObject, nil
}

func (b *filesystemBackend) DeleteCalendarObject(ctx context.Context, path string) error {
Expand Down
16 changes: 8 additions & 8 deletions services/ccs/pkg/storage/filesystem_carddav.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (

"github.com/rs/zerolog/log"

"github.com/DeepDiver1975/go-webdav"
"github.com/DeepDiver1975/go-webdav/carddav"
"github.com/emersion/go-vcard"
"github.com/emersion/go-webdav"
"github.com/emersion/go-webdav/carddav"
)

const addressBookFileName = "addressbook.json"
Expand Down Expand Up @@ -311,20 +311,20 @@ func (b *filesystemBackend) QueryAddressObjects(ctx context.Context, urlPath str
return filtered, err
}

func (b *filesystemBackend) PutAddressObject(ctx context.Context, objPath string, card vcard.Card, opts *carddav.PutAddressObjectOptions) (loc string, err error) {
func (b *filesystemBackend) PutAddressObject(ctx context.Context, objPath string, card vcard.Card, opts *carddav.PutAddressObjectOptions) (*carddav.AddressObject, error) {
log.Debug().Str("path", objPath).Msg("filesystem.PutAddressObject()")

// TODO: validate carddav ???
localPath, err := b.safeLocalCardDAVPath(ctx, objPath)
if err != nil {
return "", err
return nil, err
}

var buf bytes.Buffer
enc := vcard.NewEncoder(&buf)
err = enc.Encode(card)
if err != nil {
return "", err
return nil, err
}

req := metadata.UploadRequest{
Expand All @@ -343,17 +343,17 @@ func (b *filesystemBackend) PutAddressObject(ctx context.Context, objPath string
} else if opts.IfMatch.IsSet() {
want, err := opts.IfMatch.ETag()
if err != nil {
return "", webdav.NewHTTPError(http.StatusBadRequest, err)
return nil, webdav.NewHTTPError(http.StatusBadRequest, err)
}
req.IfMatchEtag = want
}

_, err = b.storage.Upload(ctx, req)
if err != nil {
return "", err
return nil, err
}

return objPath, nil
return b.GetAddressObject(ctx, objPath, nil)
}

func (b *filesystemBackend) DeleteAddressObject(ctx context.Context, path string) error {
Expand Down
15 changes: 15 additions & 0 deletions vendor/github.com/DeepDiver1975/go-webdav/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7d52439

Please sign in to comment.