MCPcopy Create free account
hub / github.com/ZToolsCenter/ZTools / walk

Method walk

src/main/core/sync/webdavClient.ts:167–192  ·  view source on GitHub ↗
(dirPath: string)

Source from the content-addressed store, hash-verified

165 const excludeDirs = new Set([`${basePath}/attachments`, `${basePath}/plugins`])
166
167 const walk = async (dirPath: string): Promise<void> => {
168 const response = await this.client!.getDirectoryContents(dirPath, {
169 details: true
170 })
171 const contents = Array.isArray(response) ? response : (response as any).data
172 if (!Array.isArray(contents)) return
173
174 for (const item of contents) {
175 if (item.type === 'directory') {
176 // 标准化路径:移除尾部斜杠,确保 excludeDirs 判断一致
177 const filename = item.filename.replace(/\/+$/, '')
178 if (!excludeDirs.has(filename)) {
179 await walk(filename)
180 }
181 } else if (item.type === 'file' && item.filename.endsWith('.json')) {
182 // 从完整路径提取 docId:去掉 basePath/ 前缀和 .json 后缀
183 const relativePath = item.filename.substring(basePath.length + 1)
184 const encodedDocId = relativePath.replace(/\.json$/, '')
185 const docId = decodeDocPath(encodedDocId)
186 results.push({
187 docId,
188 lastModified: new Date(item.lastmod).getTime()
189 })
190 }
191 }
192 }
193
194 await walk(basePath)
195 return results

Callers

nothing calls this directly

Calls 1

decodeDocPathFunction · 0.85

Tested by

no test coverage detected