Skip to content

Commit 80cb07e

Browse files
committed
fix webdav error
1 parent faae71f commit 80cb07e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

storage_webdav.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"os"
3030
"path"
3131
"strconv"
32+
"strings"
3233

3334
"github.com/emersion/go-webdav"
3435
"gopkg.in/yaml.v3"
@@ -118,6 +119,11 @@ func (s *WebDavStorage) SetOptions(newOpts any) {
118119
s.opt = *(newOpts.(*WebDavStorageOption))
119120
}
120121

122+
func webdavIsHTTPError(err error, code int) bool {
123+
expect := fmt.Sprintf("%v %v", code, http.StatusText(code))
124+
return strings.Contains(err.Error(), expect)
125+
}
126+
121127
func (s *WebDavStorage) Init(ctx context.Context) (err error) {
122128
if alias := s.opt.Alias; alias != "" {
123129
user, ok := config.WebdavUsers[alias]
@@ -152,8 +158,10 @@ func (s *WebDavStorage) Init(ctx context.Context) (err error) {
152158
return
153159
}
154160

155-
if err = s.cli.Mkdir(ctx, "measure"); err != nil {
156-
logErrorf("Could not create measure folder for %s: %v", s.String(), err)
161+
if err := s.cli.Mkdir(ctx, "measure"); err != nil {
162+
if !webdavIsHTTPError(err, http.StatusConflict) {
163+
logErrorf("Could not create measure folder for %s: %v", s.String(), err)
164+
}
157165
}
158166
if s.opt.PreGenMeasures {
159167
logInfo("Creating measure files at %s", s.String())

0 commit comments

Comments
 (0)