mirror of
https://github.com/requarks/wiki.git
synced 2026-10-12 05:54:49 -05:00
fix: missing offline check for locales + updates tasks
This commit is contained in:
7 files changed
+63
-11
No files matched your search
@@ -2186,7 +2186,12 @@ async function routes(app: FastifyInstance) {
|
||||
}
|
||||
}
|
||||
},
|
||||
async (req) => {
|
||||
async (req, reply) => {
|
||||
// -> The task skips itself offline, which here would answer with whatever was stored last
|
||||
if (WIKI.config.offline) {
|
||||
return reply.badRequest('Wiki.js is in offline mode and cannot check for updates.')
|
||||
}
|
||||
|
||||
const renderJob = await WIKI.scheduler.addJob({
|
||||
task: 'checkVersion',
|
||||
maxRetries: 0,
|
||||
|
||||
+1
-3
@@ -6,7 +6,7 @@ name: Wiki.js
|
||||
defaults:
|
||||
config:
|
||||
# File defaults
|
||||
port: 80
|
||||
port: 3000
|
||||
db:
|
||||
host: localhost
|
||||
port: 5432
|
||||
@@ -19,8 +19,6 @@ defaults:
|
||||
schema: wiki
|
||||
ssl:
|
||||
enabled: false
|
||||
pool:
|
||||
min: 1
|
||||
bindIP: 0.0.0.0
|
||||
logLevel: info
|
||||
logFormat: default
|
||||
|
||||
@@ -2,6 +2,7 @@ import { readdir, stat, readFile } from 'node:fs/promises'
|
||||
import path from 'node:path'
|
||||
import { locales as localesTable } from '../db/schema.ts'
|
||||
import { eq, sql } from 'drizzle-orm'
|
||||
import { CustomError } from '../helpers/common.ts'
|
||||
|
||||
/** Where the locale packages published for this major version live. */
|
||||
const REMOTE_BASE_URL = 'https://github.com/requarks/wiki-locales/raw/main'
|
||||
@@ -288,8 +289,19 @@ class Locales {
|
||||
|
||||
/**
|
||||
* Read the list of locale packages published upstream.
|
||||
*
|
||||
* Everything that downloads a locale goes through here first, so this is the one place offline
|
||||
* mode has to refuse it. A `CustomError` so that the admin area is told why, rather than a bare 500.
|
||||
*
|
||||
* @throws When offline mode is on, the request fails, or the response is not the expected list
|
||||
*/
|
||||
async fetchRemoteMetadata(): Promise<RemoteLocale[]> {
|
||||
if (WIKI.config.offline) {
|
||||
throw new CustomError(
|
||||
'localesOffline',
|
||||
'Wiki.js is in offline mode and cannot reach the locale repository. Upload a locale file instead.'
|
||||
)
|
||||
}
|
||||
const resp = await fetch(`${REMOTE_BASE_URL}/metadata.json`)
|
||||
if (!resp.ok) {
|
||||
throw new Error(`Remote locale metadata could not be fetched (HTTP ${resp.status}).`)
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
export async function task(): Promise<void> {
|
||||
// -> Nothing to reach, and a nightly failure saying so would be noise rather than news
|
||||
if (WIKI.config.offline) {
|
||||
return
|
||||
}
|
||||
|
||||
WIKI.logger.info('Checking for latest version...')
|
||||
|
||||
try {
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
/**
|
||||
* Bring the locale list in step with what is published upstream.
|
||||
*
|
||||
* Scheduled nightly, and run on demand from the admin area's Fetch Locales action — which passes
|
||||
* `force`, since `update.locales: false` is there to stop the wiki phoning home on its own, not to
|
||||
* refuse an administrator who asked for this explicitly.
|
||||
* Scheduled nightly. The admin area's Fetch Locales action does the same work but does not come
|
||||
* through here: `POST /locales/fetch` calls `updateFromRemote` directly, since its dialog waits for
|
||||
* the counts. So `update.locales: false`, which is there to stop the wiki phoning home on its own,
|
||||
* never refuses an administrator who asked for this explicitly.
|
||||
*/
|
||||
export async function task(payload?: { force?: boolean }): Promise<void> {
|
||||
if (!payload?.force && WIKI.config.update?.locales === false) {
|
||||
export async function task(): Promise<void> {
|
||||
if (WIKI.config.update?.locales === false) {
|
||||
return
|
||||
}
|
||||
// -> Nothing to reach, and a nightly failure saying so would be noise rather than news
|
||||
if (WIKI.config.offline) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
+28
-2
@@ -62,8 +62,16 @@ logFormat: default
|
||||
# ---------------------------------------------------------------------
|
||||
# Offline Mode
|
||||
# ---------------------------------------------------------------------
|
||||
# If your server cannot access the internet. Set to true and manually
|
||||
# download the offline files for sideloading.
|
||||
# Set to true if your server cannot access the internet. Wiki.js then
|
||||
# makes no request of its own to upstream services:
|
||||
# - Icons: icon sets cannot be added, and only icons the wiki has
|
||||
# already stored can be used. The interface's own icons are built in
|
||||
# and unaffected.
|
||||
# - Locales: nothing is downloaded. Install a locale by uploading its
|
||||
# file instead (Admin > Locale).
|
||||
# - Update checks: skipped.
|
||||
# Services you configure yourself (authentication providers, storage
|
||||
# targets, mail, Akismet) are still contacted, since you chose them.
|
||||
|
||||
offline: false
|
||||
|
||||
@@ -101,6 +109,24 @@ scheduler:
|
||||
# least 1), which respects a container's CPU limit.
|
||||
workers: auto
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Database Connection Pool
|
||||
# ---------------------------------------------------------------------
|
||||
# Passed as-is to the PostgreSQL connection pool (node-postgres) of
|
||||
# each instance, so any of its options is accepted:
|
||||
# https://node-postgres.com/apis/pool
|
||||
#
|
||||
# `max` (default 10) is the one worth knowing: with several instances
|
||||
# behind a load balancer, each opens up to `max` connections, and the
|
||||
# total must stay under the server's `max_connections`. Three of each
|
||||
# instance's connections are held open for good (event, scheduler and
|
||||
# collaboration listeners), so `max` must be well above 3 or queries
|
||||
# will wait for a connection that never comes free.
|
||||
# Worker threads ignore this and use one connection each.
|
||||
|
||||
# pool:
|
||||
# max: 10
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Dev Mode
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="96px" height="96px"><linearGradient id="RBZbGDlrJgwaS0JPaDcoma" x1="32.36" x2="15.528" y1="-594.36" y2="-577.528" gradientTransform="matrix(1 0 0 -1 0 -562)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#fff"/><stop offset=".242" stop-color="#f2f2f2"/><stop offset="1" stop-color="#ccc"/></linearGradient><circle cx="24" cy="24" r="12" fill="url(#RBZbGDlrJgwaS0JPaDcoma)"/><path fill="#808991" d="M43.407,19.243c-2.389-0.029-4.702-1.274-5.983-3.493c-1.233-2.136-1.208-4.649-0.162-6.693 c-2.125-1.887-4.642-3.339-7.43-4.188C28.577,6.756,26.435,8,24,8s-4.577-1.244-5.831-3.131c-2.788,0.849-5.305,2.301-7.43,4.188 c1.046,2.044,1.071,4.557-0.162,6.693c-1.281,2.219-3.594,3.464-5.983,3.493C4.22,20.77,4,22.358,4,24 c0,1.284,0.133,2.535,0.364,3.752c2.469-0.051,4.891,1.208,6.213,3.498c1.368,2.37,1.187,5.204-0.22,7.345 c2.082,1.947,4.573,3.456,7.34,4.375C18.827,40.624,21.221,39,24,39s5.173,1.624,6.303,3.971c2.767-0.919,5.258-2.428,7.34-4.375 c-1.407-2.141-1.588-4.975-0.22-7.345c1.322-2.29,3.743-3.549,6.213-3.498C43.867,26.535,44,25.284,44,24 C44,22.358,43.78,20.77,43.407,19.243z M36,24c0,1.626-0.327,3.176-0.913,4.59l-5.166-3.66C29.968,24.626,30,24.317,30,24 c0-2.611-1.671-4.827-4-5.651V12.18C31.673,13.134,36,18.056,36,24z M22,12.18v6.169c-2.329,0.825-4,3.04-4,5.651 c0,0.317,0.032,0.626,0.079,0.93l-5.166,3.66C12.327,27.176,12,25.626,12,24C12,18.056,16.327,13.134,22,12.18z M24,36 c-3.561,0-6.75-1.56-8.948-4.023l4.953-3.509C21.066,29.418,22.464,30,24,30s2.934-0.582,3.995-1.532l4.953,3.509 C30.75,34.44,27.561,36,24,36z"/></svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
Reference in new issue
Block a user