Backend: Code clean-up in album download API

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2020-09-20 19:14:50 +02:00
parent 7c9bf35b27
commit 02c3cdc8b9

View File

@ -447,13 +447,12 @@ func DownloadAlbum(router *gin.RouterGroup) {
for _, f := range p {
fileName := photoprism.FileName(f.FileRoot, f.FileName)
fileAlias := f.ShareFileName()
if fs.FileExists(fileName) {
if err := addFileToZip(zipWriter, fileName, fileAlias); err != nil {
log.Error(err)
Abort(c, http.StatusInternalServerError, i18n.ErrCreateFile)
Abort(c, http.StatusInternalServerError, i18n.ErrZipFailed)
return
}
log.Infof("album: added %s as %s", txt.Quote(f.FileName), txt.Quote(fileAlias))
@ -463,6 +462,5 @@ func DownloadAlbum(router *gin.RouterGroup) {
}
log.Infof("album: archive %s created in %s", txt.Quote(zipFileName), time.Since(start))
_ = zipWriter.Close()
})
}