| 439 | } |
| 440 | |
| 441 | func (this *SQLiteFileList) remove(hash string, isDeleted bool) (notFound bool, err error) { |
| 442 | var db = this.GetDB(hash) |
| 443 | |
| 444 | if !db.IsReady() { |
| 445 | return false, nil |
| 446 | } |
| 447 | |
| 448 | // HashMap中不存在,则确定不存在 |
| 449 | if !db.hashMap.Exist(hash) { |
| 450 | return true, nil |
| 451 | } |
| 452 | defer db.hashMap.Delete(hash) |
| 453 | |
| 454 | // 从缓存中删除 |
| 455 | this.memoryCache.Delete(hash) |
| 456 | |
| 457 | if !isDeleted { |
| 458 | err = db.DeleteSync(hash) |
| 459 | if err != nil { |
| 460 | return false, db.WrapError(err) |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | if this.onRemove != nil { |
| 465 | // when remove file item, no any extra information needed |
| 466 | this.onRemove(nil) |
| 467 | } |
| 468 | |
| 469 | return false, nil |
| 470 | } |
| 471 | |
| 472 | // 升级老版本数据库 |
| 473 | func (this *SQLiteFileList) upgradeOldDB() { |