From 1e4d272ee757fda832e07762310444c9f96b703a Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Thu, 5 Dec 2019 19:49:05 +0100 Subject: [PATCH] Albums: Change zip file name and remove downloaded archives #15 Signed-off-by: Michael Mayer --- internal/api/zip.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/api/zip.go b/internal/api/zip.go index d4271ea6b..2b8b9bf3e 100644 --- a/internal/api/zip.go +++ b/internal/api/zip.go @@ -45,8 +45,9 @@ func CreateZip(router *gin.RouterGroup, conf *config.Config) { } zipPath := path.Join(conf.ExportPath(), "zip") - zipDate := time.Now().Format("20060201-150405") - zipBaseName := fmt.Sprintf("photos-%s.zip", zipDate) + zipToken := util.RandomToken(3) + zipYear := time.Now().Format("January-2006") + zipBaseName := fmt.Sprintf("Photos-%s-%s.zip", zipYear, zipToken) zipFileName := fmt.Sprintf("%s/%s", zipPath, zipBaseName) if err := os.MkdirAll(zipPath, 0700); err != nil { @@ -112,6 +113,9 @@ func DownloadZip(router *gin.RouterGroup, conf *config.Config) { c.File(zipFileName) + if err := os.Remove(zipFileName); err != nil { + log.Errorf("zip: could not remove \"%s\" %s", zipFileName, err.Error()) + } }) }