MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / writeLockInfo

Function writeLockInfo

server/webdav/xml.go:84–102  ·  view source on GitHub ↗
(w io.Writer, token string, ld LockDetails)

Source from the content-addressed store, hash-verified

82}
83
84func writeLockInfo(w io.Writer, token string, ld LockDetails) (int, error) {
85 depth := "infinity"
86 if ld.ZeroDepth {
87 depth = "0"
88 }
89 timeout := ld.Duration / time.Second
90 return fmt.Fprintf(w, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"+
91 "<D:prop xmlns:D=\"DAV:\"><D:lockdiscovery><D:activelock>\n"+
92 " <D:locktype><D:write/></D:locktype>\n"+
93 " <D:lockscope><D:exclusive/></D:lockscope>\n"+
94 " <D:depth>%s</D:depth>\n"+
95 " <D:owner>%s</D:owner>\n"+
96 " <D:timeout>Second-%d</D:timeout>\n"+
97 " <D:locktoken><D:href>%s</D:href></D:locktoken>\n"+
98 " <D:lockroot><D:href>%s</D:href></D:lockroot>\n"+
99 "</D:activelock></D:lockdiscovery></D:prop>",
100 depth, ld.OwnerXML, timeout, escape(token), escape(ld.Root),
101 )
102}
103
104func escape(s string) string {
105 for i := 0; i < len(s); i++ {

Callers 1

handleLockMethod · 0.85

Calls 1

escapeFunction · 0.85

Tested by

no test coverage detected