From 6c4fc42415c0c53fa87d0488e8a370c49ca1bc01 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Sun, 20 Feb 2022 17:36:51 +0100 Subject: [PATCH] API: Add Explicit Cache Header for Existing Thumbs #822 --- internal/acl/acl.go | 2 +- internal/api/api.go | 2 +- internal/api/photo_thumb.go | 10 ++++------ internal/auto/auto.go | 2 +- internal/classify/classify.go | 2 +- internal/crop/crop.go | 2 +- internal/face/face.go | 2 +- internal/form/form.go | 2 +- internal/hub/hub.go | 2 +- internal/hub/places/places.go | 2 +- internal/i18n/i18n.go | 2 +- internal/maps/maps.go | 2 +- internal/meta/meta.go | 2 +- internal/migrate/migrate.go | 2 +- internal/nsfw/nsfw.go | 2 +- internal/photoprism/photoprism.go | 2 +- internal/query/query.go | 2 +- internal/remote/remote.go | 2 +- internal/remote/webdav/webdav.go | 2 +- internal/search/search.go | 2 +- internal/session/session.go | 2 +- internal/thumb/thumb.go | 2 +- internal/video/video.go | 2 +- internal/viewer/viewer.go | 2 +- internal/workers/workers.go | 2 +- 25 files changed, 28 insertions(+), 30 deletions(-) diff --git a/internal/acl/acl.go b/internal/acl/acl.go index 6a822ec36..984aea183 100644 --- a/internal/acl/acl.go +++ b/internal/acl/acl.go @@ -2,7 +2,7 @@ Package acl contains PhotoPrism's access control lists for authorizing user actions. -Copyright (c) 2018 - 2022 Michael Mayer +Copyright (c) 2018 - 2022 Michael Mayer This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/internal/api/api.go b/internal/api/api.go index bf92dc81e..393131d83 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -2,7 +2,7 @@ Package api contains PhotoPrism REST API handlers. -Copyright (c) 2018 - 2022 Michael Mayer +Copyright (c) 2018 - 2022 Michael Mayer This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/internal/api/photo_thumb.go b/internal/api/photo_thumb.go index d231e28e5..ff83288af 100644 --- a/internal/api/photo_thumb.go +++ b/internal/api/photo_thumb.go @@ -63,11 +63,10 @@ func GetThumb(router *gin.RouterGroup) { return } - AddThumbCacheHeader(c) - if download { c.FileAttachment(fileName, cropName.Jpeg()) } else { + AddThumbCacheHeader(c) c.File(fileName) } @@ -108,11 +107,10 @@ func GetThumb(router *gin.RouterGroup) { return } - AddThumbCacheHeader(c) - if c.Query("download") != "" { c.FileAttachment(cached.FileName, cached.ShareName) } else { + AddThumbCacheHeader(c) c.File(cached.FileName) } @@ -122,6 +120,7 @@ func GetThumb(router *gin.RouterGroup) { // Return existing thumbs straight away. if !download { if fileName, err := thumb.FileName(fileHash, conf.ThumbPath(), size.Width, size.Height, size.Options...); err == nil && fs.FileExists(fileName) { + AddThumbCacheHeader(c) c.File(fileName) return } @@ -202,11 +201,10 @@ func GetThumb(router *gin.RouterGroup) { cache.SetDefault(cacheKey, ThumbCache{thumbnail, f.ShareBase(0)}) log.Debugf("cached %s [%s]", cacheKey, time.Since(start)) - AddThumbCacheHeader(c) - if download { c.FileAttachment(thumbnail, f.DownloadName(DownloadName(c), 0)) } else { + AddThumbCacheHeader(c) c.File(thumbnail) } }) diff --git a/internal/auto/auto.go b/internal/auto/auto.go index 04d883d90..405187eda 100644 --- a/internal/auto/auto.go +++ b/internal/auto/auto.go @@ -2,7 +2,7 @@ Package auto contains index & import background workers. -Copyright (c) 2018 - 2022 Michael Mayer +Copyright (c) 2018 - 2022 Michael Mayer This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/internal/classify/classify.go b/internal/classify/classify.go index f3ece5862..972547618 100644 --- a/internal/classify/classify.go +++ b/internal/classify/classify.go @@ -2,7 +2,7 @@ Package classify encapsulates image classification using TensorFlow. -Copyright (c) 2018 - 2022 Michael Mayer +Copyright (c) 2018 - 2022 Michael Mayer This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/internal/crop/crop.go b/internal/crop/crop.go index 26f3688b9..4ff8ce4ef 100644 --- a/internal/crop/crop.go +++ b/internal/crop/crop.go @@ -2,7 +2,7 @@ Package crop provides image crop data structures and helpers. -Copyright (c) 2018 - 2022 Michael Mayer +Copyright (c) 2018 - 2022 Michael Mayer This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/internal/face/face.go b/internal/face/face.go index 54d4c01fb..9a82e4ca2 100644 --- a/internal/face/face.go +++ b/internal/face/face.go @@ -2,7 +2,7 @@ Package face provides facial recognition. -Copyright (c) 2018 - 2022 Michael Mayer +Copyright (c) 2018 - 2022 Michael Mayer This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/internal/form/form.go b/internal/form/form.go index 170adfdea..884bdc847 100644 --- a/internal/form/form.go +++ b/internal/form/form.go @@ -2,7 +2,7 @@ Package form contains tagged structs for input value validation. -Copyright (c) 2018 - 2022 Michael Mayer +Copyright (c) 2018 - 2022 Michael Mayer This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/internal/hub/hub.go b/internal/hub/hub.go index 5356aa809..ebe4443ab 100644 --- a/internal/hub/hub.go +++ b/internal/hub/hub.go @@ -2,7 +2,7 @@ Package hub contains backend api config & clients. -Copyright (c) 2018 - 2022 Michael Mayer +Copyright (c) 2018 - 2022 Michael Mayer This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/internal/hub/places/places.go b/internal/hub/places/places.go index b7223fc5e..7b908d2bc 100644 --- a/internal/hub/places/places.go +++ b/internal/hub/places/places.go @@ -2,7 +2,7 @@ Package places encapsulates the PhotoPrism Places geolocation API. -Copyright (c) 2018 - 2022 Michael Mayer +Copyright (c) 2018 - 2022 Michael Mayer This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/internal/i18n/i18n.go b/internal/i18n/i18n.go index 61ad7e104..48ef00be8 100644 --- a/internal/i18n/i18n.go +++ b/internal/i18n/i18n.go @@ -2,7 +2,7 @@ Package i18n contains PhotoPrism status and error message strings. -Copyright (c) 2018 - 2022 Michael Mayer +Copyright (c) 2018 - 2022 Michael Mayer This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/internal/maps/maps.go b/internal/maps/maps.go index 3c64f9cb5..70d9db9f5 100644 --- a/internal/maps/maps.go +++ b/internal/maps/maps.go @@ -2,7 +2,7 @@ Package maps encapsulates external geolocation APIs. -Copyright (c) 2018 - 2022 Michael Mayer +Copyright (c) 2018 - 2022 Michael Mayer This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/internal/meta/meta.go b/internal/meta/meta.go index 51d1e9fb8..91249c8b9 100644 --- a/internal/meta/meta.go +++ b/internal/meta/meta.go @@ -2,7 +2,7 @@ Package meta encapsulates image metadata decoding and conversion to/from XMP and Exif. -Copyright (c) 2018 - 2022 Michael Mayer +Copyright (c) 2018 - 2022 Michael Mayer This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/internal/migrate/migrate.go b/internal/migrate/migrate.go index d44787d29..166d60054 100644 --- a/internal/migrate/migrate.go +++ b/internal/migrate/migrate.go @@ -2,7 +2,7 @@ Package migrate provides database schema migrations. -Copyright (c) 2018 - 2022 Michael Mayer +Copyright (c) 2018 - 2022 Michael Mayer This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/internal/nsfw/nsfw.go b/internal/nsfw/nsfw.go index 6ba6c0491..2e97febb8 100644 --- a/internal/nsfw/nsfw.go +++ b/internal/nsfw/nsfw.go @@ -2,7 +2,7 @@ Package nsfw uses TensorFlow to detect images that may not be safe for work. -Copyright (c) 2018 - 2022 Michael Mayer +Copyright (c) 2018 - 2022 Michael Mayer This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/internal/photoprism/photoprism.go b/internal/photoprism/photoprism.go index 60d43df27..c1d84562e 100644 --- a/internal/photoprism/photoprism.go +++ b/internal/photoprism/photoprism.go @@ -2,7 +2,7 @@ Package photoprism contains PhotoPrism core functionality. -Copyright (c) 2018 - 2022 Michael Mayer +Copyright (c) 2018 - 2022 Michael Mayer This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/internal/query/query.go b/internal/query/query.go index 7ec0b8d60..75d13ff19 100644 --- a/internal/query/query.go +++ b/internal/query/query.go @@ -2,7 +2,7 @@ Package query provides frequently used database queries for use in commands and API. -Copyright (c) 2018 - 2022 Michael Mayer +Copyright (c) 2018 - 2022 Michael Mayer This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/internal/remote/remote.go b/internal/remote/remote.go index dcd2401ef..185752e78 100644 --- a/internal/remote/remote.go +++ b/internal/remote/remote.go @@ -5,7 +5,7 @@ Package remote implements remote service sync and uploads. See also: - RClone (https://rclone.org/), a popular Go tool for syncing data with remote services -Copyright (c) 2018 - 2022 Michael Mayer +Copyright (c) 2018 - 2022 Michael Mayer This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/internal/remote/webdav/webdav.go b/internal/remote/webdav/webdav.go index af6413c0d..a3e0d6096 100644 --- a/internal/remote/webdav/webdav.go +++ b/internal/remote/webdav/webdav.go @@ -2,7 +2,7 @@ Package webdav implements sharing with WebDAV servers. -Copyright (c) 2018 - 2022 Michael Mayer +Copyright (c) 2018 - 2022 Michael Mayer This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/internal/search/search.go b/internal/search/search.go index 40ddd734d..d961e7c5a 100644 --- a/internal/search/search.go +++ b/internal/search/search.go @@ -2,7 +2,7 @@ Package search performs common index search queries. -Copyright (c) 2018 - 2022 Michael Mayer +Copyright (c) 2018 - 2022 Michael Mayer This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/internal/session/session.go b/internal/session/session.go index 331042d63..ba57ca14c 100644 --- a/internal/session/session.go +++ b/internal/session/session.go @@ -2,7 +2,7 @@ Package session provides session storage and management. -Copyright (c) 2018 - 2022 Michael Mayer +Copyright (c) 2018 - 2022 Michael Mayer This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/internal/thumb/thumb.go b/internal/thumb/thumb.go index 35bc9b333..c1df69cd5 100644 --- a/internal/thumb/thumb.go +++ b/internal/thumb/thumb.go @@ -2,7 +2,7 @@ Package thumb provides JPEG resampling and thumbnail generation. -Copyright (c) 2018 - 2022 Michael Mayer +Copyright (c) 2018 - 2022 Michael Mayer This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/internal/video/video.go b/internal/video/video.go index 776a5d3ef..3aad2c7d2 100644 --- a/internal/video/video.go +++ b/internal/video/video.go @@ -2,7 +2,7 @@ Package video provides video file related types and functions. -Copyright (c) 2018 - 2022 Michael Mayer +Copyright (c) 2018 - 2022 Michael Mayer This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/internal/viewer/viewer.go b/internal/viewer/viewer.go index 167640d1a..95f6d7602 100644 --- a/internal/viewer/viewer.go +++ b/internal/viewer/viewer.go @@ -2,7 +2,7 @@ Package viewer provides photo viewer data structures and utility functions. -Copyright (c) 2018 - 2022 Michael Mayer +Copyright (c) 2018 - 2022 Michael Mayer This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published diff --git a/internal/workers/workers.go b/internal/workers/workers.go index 20f23fb0e..4f6b7b132 100644 --- a/internal/workers/workers.go +++ b/internal/workers/workers.go @@ -2,7 +2,7 @@ Package workers contains background workers for file sync & metadata optimization. -Copyright (c) 2018 - 2022 Michael Mayer +Copyright (c) 2018 - 2022 Michael Mayer This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published