1
0
mirror of https://github.com/pocket-id/pocket-id.git synced 2026-02-04 12:46:45 +00:00

feat: add VERSION_CHECK_DISABLED environment variable (#1254)

This commit is contained in:
Jasper Bernhardt
2026-01-19 00:28:24 +01:00
committed by GitHub
parent 53ef61a3e5
commit 0978a89fcc
3 changed files with 13 additions and 2 deletions

View File

@@ -50,6 +50,7 @@ type EnvConfigSchema struct {
InternalAppURL string `env:"INTERNAL_APP_URL"` InternalAppURL string `env:"INTERNAL_APP_URL"`
UiConfigDisabled bool `env:"UI_CONFIG_DISABLED"` UiConfigDisabled bool `env:"UI_CONFIG_DISABLED"`
DisableRateLimiting bool `env:"DISABLE_RATE_LIMITING"` DisableRateLimiting bool `env:"DISABLE_RATE_LIMITING"`
VersionCheckDisabled bool `env:"VERSION_CHECK_DISABLED"`
StaticApiKey string `env:"STATIC_API_KEY" options:"file"` StaticApiKey string `env:"STATIC_API_KEY" options:"file"`
FileBackend string `env:"FILE_BACKEND" options:"toLower"` FileBackend string `env:"FILE_BACKEND" options:"toLower"`

View File

@@ -10,6 +10,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/pocket-id/pocket-id/backend/internal/common"
"github.com/pocket-id/pocket-id/backend/internal/utils" "github.com/pocket-id/pocket-id/backend/internal/utils"
) )
@@ -31,6 +32,10 @@ func NewVersionService(httpClient *http.Client) *VersionService {
} }
func (s *VersionService) GetLatestVersion(ctx context.Context) (string, error) { func (s *VersionService) GetLatestVersion(ctx context.Context) (string, error) {
if common.EnvConfig.VersionCheckDisabled {
return "", nil
}
version, err := s.cache.GetOrFetch(ctx, func(ctx context.Context) (string, error) { version, err := s.cache.GetOrFetch(ctx, func(ctx context.Context) (string, error) {
reqCtx, cancel := context.WithTimeout(ctx, 5*time.Second) reqCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel() defer cancel()

View File

@@ -10,8 +10,13 @@ export const load: LayoutLoad = async () => {
let isUpToDate = true; let isUpToDate = true;
try { try {
newestVersion = await versionService.getNewestVersion(); newestVersion = await versionService.getNewestVersion();
isUpToDate = newestVersion === currentVersion; // If newestVersion is empty, it means the check is disabled or failed.
} catch {} // In this case, we assume the version is up to date.
isUpToDate = newestVersion === '' || newestVersion === currentVersion;
} catch {
// If the request fails, assume up-to-date to avoid showing a warning.
isUpToDate = true;
}
const versionInformation: AppVersionInformation = { const versionInformation: AppVersionInformation = {
currentVersion: versionService.getCurrentVersion(), currentVersion: versionService.getCurrentVersion(),