MCPcopy Index your code
hub / github.com/TruthHun/BookStack / DeleteOldEbook

Method DeleteOldEbook

models/ebook.go:438–457  ·  view source on GitHub ↗

DeleteOldEbook 删除旧电子书 1. 相同ext,状态为 Success 之外的记录以及电子书文件

(bookId int, ext string, ignoreEbookId int)

Source from the content-addressed store, hash-verified

436// DeleteOldEbook 删除旧电子书
437// 1. 相同ext,状态为 Success 之外的记录以及电子书文件
438func (m *Ebook) DeleteOldEbook(bookId int, ext string, ignoreEbookId int) {
439 var (
440 ebooks []Ebook
441 o = orm.NewOrm()
442 )
443
444 query := o.QueryTable(m).Filter("book_id", bookId).Filter("ext", ext)
445 query.All(&ebooks)
446 if len(ebooks) == 0 {
447 return
448 }
449
450 for _, ebook := range ebooks {
451 if ebook.Id == ignoreEbookId {
452 continue
453 }
454 utils.DeleteFile(ebook.Path)
455 o.QueryTable(m).Filter("id", ebook.Id).Delete()
456 }
457}

Callers 1

callbackMethod · 0.95

Calls 3

DeleteFileFunction · 0.92
AllMethod · 0.45
DeleteMethod · 0.45

Tested by

no test coverage detected