dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit 75c7d7590954b4e3832ec98ac358f67990f090af
parent d68b8c161508531fac6b9d4fcb32f261a04089b9
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Thu, 22 Dec 2022 16:45:33 -0800

cleanup

Diffstat:
Mpkg/database/tableUploads.go | 5+++++
Mpkg/web/handlers/handlers.go | 3+--
2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/pkg/database/tableUploads.go b/pkg/database/tableUploads.go @@ -47,6 +47,11 @@ func (u *Upload) GetContent() (os.FileInfo, []byte, error) { return fi, decFileBytes, nil } +func (u *Upload) Exists() bool { + filePath1 := filepath.Join(UploadFolder, u.FileName) + return utils.FileExists(filePath1) +} + func (u *Upload) Delete() error { if err := os.Remove(filepath.Join(UploadFolder, u.FileName)); err != nil { return err diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go @@ -3906,8 +3906,7 @@ func UploadsDownloadHandler(c echo.Context) error { if err != nil { return c.Redirect(http.StatusFound, "/") } - filePath1 := filepath.Join("uploads", file.FileName) - if !utils.FileExists(filePath1) { + if !file.Exists() { logrus.Error(filename + " does not exists") return c.Redirect(http.StatusFound, "/") }