加载Hash列表
()
| 601 | |
| 602 | // 加载Hash列表 |
| 603 | func (this *SQLiteFileListDB) loadHashMap() { |
| 604 | this.hashMapIsLoaded = false |
| 605 | |
| 606 | err := this.hashMap.Load(this) |
| 607 | if err != nil { |
| 608 | remotelogs.Error("LIST_FILE_DB", "load hash map failed: "+err.Error()+"(file: "+this.dbPath+")") |
| 609 | |
| 610 | // 自动修复错误 |
| 611 | // TODO 将来希望能尽可能恢复以往数据库中的内容 |
| 612 | if strings.Contains(err.Error(), "database is closed") || strings.Contains(err.Error(), "database disk image is malformed") { |
| 613 | _ = this.Close() |
| 614 | this.deleteDB() |
| 615 | remotelogs.Println("LIST_FILE_DB", "recreating the database (file:"+this.dbPath+") ...") |
| 616 | err = this.Open(this.dbPath) |
| 617 | if err != nil { |
| 618 | remotelogs.Error("LIST_FILE_DB", "recreate the database failed: "+err.Error()+" (file:"+this.dbPath+")") |
| 619 | } else { |
| 620 | _ = this.Init() |
| 621 | } |
| 622 | } |
| 623 | return |
| 624 | } |
| 625 | |
| 626 | this.hashMapIsLoaded = true |
| 627 | } |