mirror of
https://github.com/go-shiori/shiori.git
synced 2025-02-22 15:06:04 +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"
|
"time"
|
||||||
|
|
||||||
"github.com/go-shiori/shiori/internal/database"
|
"github.com/go-shiori/shiori/internal/database"
|
||||||
|
"github.com/go-shiori/shiori/pkg/warc"
|
||||||
"github.com/julienschmidt/httprouter"
|
"github.com/julienschmidt/httprouter"
|
||||||
cch "github.com/patrickmn/go-cache"
|
cch "github.com/patrickmn/go-cache"
|
||||||
"github.com/sirupsen/logrus"
|
"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),
|
ArchiveCache: cch.New(time.Minute, 5*time.Minute),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hdl.ArchiveCache.OnEvicted(func(key string, data interface{}) {
|
||||||
|
archive := data.(*warc.Archive)
|
||||||
|
archive.Close()
|
||||||
|
})
|
||||||
|
|
||||||
// Create router
|
// Create router
|
||||||
router := httprouter.New()
|
router := httprouter.New()
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ func NewArchive(req ArchivalRequest, dstPath string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create archive: %v", err)
|
return fmt.Errorf("failed to create archive: %v", err)
|
||||||
}
|
}
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
// Create archiver
|
// Create archiver
|
||||||
arc := &archiver.Archiver{
|
arc := &archiver.Archiver{
|
||||||
|
|
Loading…
Reference in a new issue