commit aadf098e5675028853a140d6d60f0f89344524c8
parent c517753e91d46629f7b78c574e8be4b35ab14c7f
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Thu, 26 Jan 2023 11:38:50 -0800
can have multiple filedrop links
Diffstat:
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/pkg/database/tableFiledrops.go b/pkg/database/tableFiledrops.go
@@ -40,6 +40,7 @@ func GetFiledrops() (out []Filedrop, err error) {
func CreateFiledrop() (out Filedrop, err error) {
out.UUID = uuid.New().String()
+ out.FileName = utils.MD5([]byte(utils.GenerateToken32()))
err = DB.Save(&out).Error
return
}
diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go
@@ -4179,7 +4179,7 @@ func FileDropHandler(c echo.Context) error {
if err != nil {
return c.Redirect(http.StatusFound, "/")
}
- if filedrop.FileName != "" {
+ if filedrop.FileSize > 0 {
return c.Redirect(http.StatusFound, "/")
}
@@ -4205,8 +4205,7 @@ func FileDropHandler(c echo.Context) error {
return c.Render(http.StatusOK, filedropTmplName, data)
}
- newFileName := utils.MD5([]byte(utils.GenerateToken32()))
- outFile, err := os.OpenFile(filepath.Join(database.FiledropFolder, newFileName), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
+ outFile, err := os.OpenFile(filepath.Join(database.FiledropFolder, filedrop.FileName), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
if err != nil {
data.Error = err.Error()
return c.Render(http.StatusOK, filedropTmplName, data)
@@ -4224,7 +4223,6 @@ func FileDropHandler(c echo.Context) error {
}
filedrop.IV = encrypter.Meta().IV
- filedrop.FileName = newFileName
filedrop.OrigFileName = origFileName
filedrop.FileSize = written
filedrop.DoSave()
diff --git a/pkg/web/public/views/pages/admin/filedrops.gohtml b/pkg/web/public/views/pages/admin/filedrops.gohtml
@@ -33,7 +33,7 @@
{{ range .Data.Filedrops }}
<tr>
<td>
- {{ if .FileName }}
+ {{ if .FileSize }}
{{ .UUID }}
{{ else }}
<a href="/file-drop/{{ .UUID }}">{{ .UUID }}</a>