indexRestoredFilesAsync 异步为恢复的文件建立 Elasticsearch 索引
(eid int64, file *model.File)
| 168 | |
| 169 | // indexRestoredFilesAsync 异步为恢复的文件建立 Elasticsearch 索引 |
| 170 | func indexRestoredFilesAsync(eid int64, file *model.File) { |
| 171 | // 如果恢复的是文件夹,则需要为文件夹下所有文件建立索引 |
| 172 | if file.Type == model.FILE_TYPE_DIR { |
| 173 | // 获取文件夹下所有文件 |
| 174 | children, err := model.GetChildrenByPathPrefix(eid, file.Path) |
| 175 | if err != nil { |
| 176 | logger.SysLogf("获取文件夹下文件列表失败: eid=%d path=%s err=%v", eid, file.Path, err) |
| 177 | } else { |
| 178 | // 为文件夹下所有文件建立索引 |
| 179 | for _, child := range children { |
| 180 | if child.Type == model.FILE_TYPE_FILE && !child.IsDeleted { |
| 181 | elasticsearch.SyncFileToES(&child, "create") |
| 182 | common.DeleteFileStopCache(child.ID) // 设置文件为已恢复状态 |
| 183 | } |
| 184 | } |
| 185 | } |
| 186 | } else { |
| 187 | // 为单个文件建立索引 |
| 188 | elasticsearch.SyncFileToES(file, "create") |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | // HardDeleteFile godoc |
| 193 | // @Summary 管理员彻底删除文件 |