MCPcopy Create free account
hub / github.com/CatMuse/HiNote / handleFileRename

Method handleFileRename

src/storage/HiNoteDataManager.ts:153–173  ·  view source on GitHub ↗

* 处理文件重命名 * @param oldPath 旧路径 * @param newPath 新路径

(oldPath: string, newPath: string)

Source from the content-addressed store, hash-verified

151 * @param newPath 新路径
152 */
153 async handleFileRename(oldPath: string, newPath: string): Promise<void> {
154 const oldStoragePath = this.getStoragePathForFile(oldPath);
155 const newStoragePath = this.getStoragePathForFile(newPath);
156
157 try {
158 // 检查旧文件是否存在
159 const content = await this.app.vault.adapter.read(oldStoragePath);
160
161 // 写入新位置
162 await this.app.vault.adapter.write(newStoragePath, content);
163
164 // 删除旧文件
165 await this.app.vault.adapter.remove(oldStoragePath);
166
167 // 更新映射
168 this.fileMappingStore.delete(oldPath);
169 await this.saveFileMapping();
170 } catch {
171 // 旧文件可能不存在,忽略错误
172 }
173 }
174
175 /**
176 * 获取所有高亮文件列表

Callers

nothing calls this directly

Calls 4

getStoragePathForFileMethod · 0.95
saveFileMappingMethod · 0.95
removeMethod · 0.80
deleteMethod · 0.80

Tested by

no test coverage detected