Skip to content

Commit

Permalink
fix: support for Microsoft WebDAV (AlistGo#6133 close AlistGo#6104)
Browse files Browse the repository at this point in the history
* Add support for Microsoft WebDAV

* add import
  • Loading branch information
wolfsilver authored and EtherealAO committed Apr 12, 2024
1 parent f4120dd commit 355fc59
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server/webdav/prop.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"net/http"
"path"
"strconv"
"strings"
"time"

"github.com/alist-org/alist/v3/internal/model"
Expand Down Expand Up @@ -385,6 +386,10 @@ func findLastModified(ctx context.Context, ls LockSystem, name string, fi model.
return fi.ModTime().UTC().Format(http.TimeFormat), nil
}
func findCreationDate(ctx context.Context, ls LockSystem, name string, fi model.Obj) (string, error) {
userAgent := ctx.Value("userAgent").(string)
if strings.Contains(strings.ToLower(userAgent), "microsoft-webdav") {
return fi.CreateTime().UTC().Format(http.TimeFormat), nil
}
return fi.CreateTime().UTC().Format(time.RFC3339), nil
}

Expand Down
3 changes: 3 additions & 0 deletions server/webdav/webdav.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package webdav // import "golang.org/x/net/webdav"

import (
"context"
"errors"
"fmt"
"net/http"
Expand Down Expand Up @@ -619,6 +620,8 @@ func (h *Handler) handlePropfind(w http.ResponseWriter, r *http.Request) (status
return status, err
}
ctx := r.Context()
userAgent := r.Header.Get("User-Agent")
ctx = context.WithValue(ctx, "userAgent", userAgent)
user := ctx.Value("user").(*model.User)
reqPath, err = user.JoinPath(reqPath)
if err != nil {
Expand Down

0 comments on commit 355fc59

Please sign in to comment.