mirror of
https://github.com/go-shiori/shiori.git
synced 2025-02-22 23:14:02 +08:00
Before updating, remove the old archive
This commit is contained in:
parent
4e38387170
commit
f4a0ee8e22
1 changed files with 5 additions and 2 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
"io"
|
||||
"net/http"
|
||||
nurl "net/url"
|
||||
"os"
|
||||
fp "path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
@ -161,12 +162,14 @@ func updateHandler(cmd *cobra.Command, args []string) {
|
|||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
// Save as archive
|
||||
// Save as archive, make sure to delete the old one first
|
||||
archivePath := fp.Join(DataDir, "archive", fmt.Sprintf("%d", book.ID))
|
||||
os.Remove(archivePath)
|
||||
|
||||
buffer := bytes.NewBuffer(nil)
|
||||
tee := io.TeeReader(resp.Body, buffer)
|
||||
|
||||
contentType := resp.Header.Get("Content-Type")
|
||||
archivePath := fp.Join(DataDir, "archive", fmt.Sprintf("%d", book.ID))
|
||||
err = warc.FromReader(tee, book.URL, contentType, archivePath)
|
||||
if err != nil {
|
||||
chProblem <- book.ID
|
||||
|
|
Loading…
Reference in a new issue