mirror of
https://github.com/go-shiori/shiori.git
synced 2025-02-21 22:43:22 +08:00
Fix: archive is never closed
This commit is contained in:
parent
cc097f50c8
commit
1399e0fc9f
2 changed files with 7 additions and 0 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-shiori/shiori/internal/database"
|
||||
"github.com/go-shiori/shiori/pkg/warc"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
cch "github.com/patrickmn/go-cache"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
@ -24,6 +25,11 @@ func ServeApp(DB database.DB, dataDir string, port int) error {
|
|||
ArchiveCache: cch.New(time.Minute, 5*time.Minute),
|
||||
}
|
||||
|
||||
hdl.ArchiveCache.OnEvicted(func(key string, data interface{}) {
|
||||
archive := data.(*warc.Archive)
|
||||
archive.Close()
|
||||
})
|
||||
|
||||
// Create router
|
||||
router := httprouter.New()
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ func NewArchive(req ArchivalRequest, dstPath string) error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("failed to create archive: %v", err)
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
// Create archiver
|
||||
arc := &archiver.Archiver{
|
||||
|
|
Loading…
Reference in a new issue