Fix modtime bug
This commit is contained in:
@@ -180,7 +180,7 @@ func (h *Handler) getChildren(name string) []os.FileInfo {
|
|||||||
if len(parts) == 2 && utils.Contains(h.getParentItems(), parts[0]) {
|
if len(parts) == 2 && utils.Contains(h.getParentItems(), parts[0]) {
|
||||||
torrentName := parts[1]
|
torrentName := parts[1]
|
||||||
if t := h.cache.GetTorrentByName(torrentName); t != nil {
|
if t := h.cache.GetTorrentByName(torrentName); t != nil {
|
||||||
return h.getFileInfos(t.Torrent)
|
return h.getFileInfos(t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@@ -267,10 +267,9 @@ func (h *Handler) Stat(ctx context.Context, name string) (os.FileInfo, error) {
|
|||||||
return f.Stat()
|
return f.Stat()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) getFileInfos(torrent *types.Torrent) []os.FileInfo {
|
func (h *Handler) getFileInfos(torrent *store.CachedTorrent) []os.FileInfo {
|
||||||
torrentFiles := torrent.GetFiles()
|
torrentFiles := torrent.GetFiles()
|
||||||
files := make([]os.FileInfo, 0, len(torrentFiles))
|
files := make([]os.FileInfo, 0, len(torrentFiles))
|
||||||
now := time.Now()
|
|
||||||
|
|
||||||
// Sort by file name since the order is lost when using the map
|
// Sort by file name since the order is lost when using the map
|
||||||
sortedFiles := make([]*types.File, 0, len(torrentFiles))
|
sortedFiles := make([]*types.File, 0, len(torrentFiles))
|
||||||
@@ -286,7 +285,7 @@ func (h *Handler) getFileInfos(torrent *types.Torrent) []os.FileInfo {
|
|||||||
name: file.Name,
|
name: file.Name,
|
||||||
size: file.Size,
|
size: file.Size,
|
||||||
mode: 0644,
|
mode: 0644,
|
||||||
modTime: now,
|
modTime: torrent.AddedOn,
|
||||||
isDir: false,
|
isDir: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type contextKey string
|
type contextKey string
|
||||||
@@ -55,7 +54,6 @@ func (h *Handler) handlePropfind(w http.ResponseWriter, r *http.Request) {
|
|||||||
rawEntries = append(rawEntries, h.getChildren(cleanPath)...)
|
rawEntries = append(rawEntries, h.getChildren(cleanPath)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
now := time.Now().UTC().Format("2006-01-02T15:04:05.000-07:00")
|
|
||||||
entries := make([]entry, 0, len(rawEntries)+1)
|
entries := make([]entry, 0, len(rawEntries)+1)
|
||||||
// Add the current file itself
|
// Add the current file itself
|
||||||
entries = append(entries, entry{
|
entries = append(entries, entry{
|
||||||
@@ -108,7 +106,7 @@ func (h *Handler) handlePropfind(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_, _ = sb.WriteString(`<d:getlastmodified>`)
|
_, _ = sb.WriteString(`<d:getlastmodified>`)
|
||||||
_, _ = sb.WriteString(now)
|
_, _ = sb.WriteString(e.modTime)
|
||||||
_, _ = sb.WriteString(`</d:getlastmodified>`)
|
_, _ = sb.WriteString(`</d:getlastmodified>`)
|
||||||
|
|
||||||
_, _ = sb.WriteString(`<d:displayname>`)
|
_, _ = sb.WriteString(`<d:displayname>`)
|
||||||
|
|||||||
Reference in New Issue
Block a user