mirror of
https://github.com/gtsteffaniak/filebrowser.git
synced 2026-11-26 08:29:41 -05:00
Compare commits
140
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6b27de197 | ||
|
|
11a4de30a1 | ||
|
|
927d738e99 | ||
|
|
05f5898732 | ||
|
|
6ecde4bf92 | ||
|
|
cb9860844c | ||
|
|
591442f7bf | ||
|
|
d5efe348c8 | ||
|
|
c5098cbf32 | ||
|
|
78261e4ecd | ||
|
|
e9134ccd2b | ||
|
|
e8ee3eb732 | ||
|
|
9740a677ce | ||
|
|
d4ef5dbfcc | ||
|
|
bbef65a808 | ||
|
|
fe6aa22eea | ||
|
|
918e1d79ea | ||
|
|
83f3ce89ae | ||
|
|
6eb21a331f | ||
|
|
27e1b7c7c4 | ||
|
|
1104776522 | ||
|
|
509c9ad933 | ||
|
|
d4ac92ead9 | ||
|
|
5f33b5e9f5 | ||
|
|
4deb8d5449 | ||
|
|
37f34f92ba | ||
|
|
0e49f80d6b | ||
|
|
2750e20326 | ||
|
|
a8bb69d1eb | ||
|
|
047e2d1b2f | ||
|
|
0ab462f9ce | ||
|
|
61dc5aef27 | ||
|
|
9fe21df8eb | ||
|
|
9f178c4d1d | ||
|
|
d0dced6afa | ||
|
|
0ceae3e645 | ||
|
|
fa441da349 | ||
|
|
79372e61f4 | ||
|
|
65493992bc | ||
|
|
b5e03f5e42 | ||
|
|
7ca14c0f31 | ||
|
|
91baad095b | ||
|
|
c34d4cfa40 | ||
|
|
1672af6a6f | ||
|
|
f7ec9392a2 | ||
|
|
8b92e5d798 | ||
|
|
325e5db8e3 | ||
|
|
ca30176e65 | ||
|
|
95b5ad9372 | ||
|
|
d029aad001 | ||
|
|
58a47def7f | ||
|
|
45624a1393 | ||
|
|
4730462a67 | ||
|
|
8f1d1b4ea2 | ||
|
|
aa42397d8d | ||
|
|
ca925db283 | ||
|
|
d2ccbc0628 | ||
|
|
7f5fb7535a | ||
|
|
0455ed28b9 | ||
|
|
17aeee995d | ||
|
|
7d4f014aca | ||
|
|
65c667e397 | ||
|
|
860016b936 | ||
|
|
487e52ab77 | ||
|
|
54dad8546a | ||
|
|
270593c2fb | ||
|
|
2800be47dc | ||
|
|
cfe9ad992e | ||
|
|
a1e41f667d | ||
|
|
75de62765e | ||
|
|
1dd6431043 | ||
|
|
e3aac7c34f | ||
|
|
6f4595699c | ||
|
|
7fcfe77c3e | ||
|
|
d053873cda | ||
|
|
2d09c76c76 | ||
|
|
4de325c6c2 | ||
|
|
a7474bfbe3 | ||
|
|
8c8190f232 | ||
|
|
8da4e2862e | ||
|
|
b46ffd410f | ||
|
|
49ba28208e | ||
|
|
6bdaeb43b3 | ||
|
|
e7c494e8e0 | ||
|
|
dabe7cd10e | ||
|
|
9a77cb0aab | ||
|
|
6d8009725e | ||
|
|
2995e0c4d9 | ||
|
|
84b3b8ebd2 | ||
|
|
28f067f808 | ||
|
|
a76b7b0415 | ||
|
|
3aa5b88a95 | ||
|
|
6aa4ffb5f8 | ||
|
|
609163735f | ||
|
|
7fb372623a | ||
|
|
10b3c985b6 | ||
|
|
a6833724da | ||
|
|
b383221a20 | ||
|
|
e98aa6fc25 | ||
|
|
e0730e8c7a | ||
|
|
435ded56c6 | ||
|
|
6f54f77d64 | ||
|
|
77a70cde6b | ||
|
|
77f5e2fe36 | ||
|
|
9766eee0d0 | ||
|
|
fdb107e2bb | ||
|
|
f9dddb117c | ||
|
|
e17f544920 | ||
|
|
c6cc8d56b4 | ||
|
|
802bcd8911 | ||
|
|
db13271bf3 | ||
|
|
bb8c5f9aa8 | ||
|
|
968ce8d066 | ||
|
|
356013a137 | ||
|
|
7c68c38479 | ||
|
|
dcca322f48 | ||
|
|
4a6e8edc28 | ||
|
|
d9c91e1125 | ||
|
|
4cdf1e71e4 | ||
|
|
9e6c2cd0a3 | ||
|
|
c102fe7556 | ||
|
|
d0591b9de4 | ||
|
|
ebe47ce643 | ||
|
|
fbbf40f877 | ||
|
|
1508d9ff21 | ||
|
|
0e318d6eaa | ||
|
|
fd64a470d3 | ||
|
+5 |
751cc56809 | ||
|
|
c5112cd51c | ||
|
|
90354e468d | ||
|
|
c35e4f33c8 | ||
|
|
474cd90e74 | ||
|
|
a483504426 | ||
|
|
36dba16fd6 | ||
|
|
5f3049ebc6 | ||
|
|
74923fbe1b | ||
|
|
59bfdbcb54 | ||
|
|
b079dd19e7 | ||
|
|
b3cbd0925e | ||
|
|
9753cfbf8b |
No files matched your search
@@ -0,0 +1,65 @@
|
||||
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
|
||||
language: "en"
|
||||
early_access: true
|
||||
reviews:
|
||||
profile: "chill"
|
||||
auto_approvals:
|
||||
enabled: true
|
||||
high_level_summary: true
|
||||
poem: false
|
||||
review_status: true
|
||||
review_details: false
|
||||
review_info: true
|
||||
review_progress: true
|
||||
related_issues: true
|
||||
related_prs: true
|
||||
suggested_labels: false
|
||||
in_progress_fortune: false
|
||||
allow_author_approval: false
|
||||
enable_prompt_for_ai_agents: true
|
||||
path_filters:
|
||||
- "!backend/swagger/**"
|
||||
- "!frontend/src/i18n/**/*.json"
|
||||
- "!frontend/src/i18n/messages.generated.ts"
|
||||
path_instructions:
|
||||
- path: "**/*.go"
|
||||
instructions: |
|
||||
- Reduce duplication where there is clear duplication found, prefer consolidated functions.
|
||||
- Prefer standard library and warn about new third-party packages that could be easily implemented with standard library code.
|
||||
- Make sure all http apis have proper sanitization for path to prevent path traversal vulnerabilities.
|
||||
- path: "frontend/src/**/*.vue"
|
||||
instructions: |
|
||||
- New files should use <script setup lang="ts"> rather than plain <script>.
|
||||
- Use the typed t() from useI18n, imported from '@/i18n/index.ts', including in templates of <script setup> files.
|
||||
- Don't flag $t() uses in older/existing <script> files.
|
||||
auto_review:
|
||||
enabled: true
|
||||
drafts: false
|
||||
auto_incremental_review: true
|
||||
auto_pause_after_reviewed_commits: 5
|
||||
base_branches:
|
||||
- .*
|
||||
finishing_touches:
|
||||
unit_tests:
|
||||
enabled: false
|
||||
autofix:
|
||||
enabled: false
|
||||
fix_ci:
|
||||
enabled: false
|
||||
resolve_merge_conflict:
|
||||
enabled: false
|
||||
tools:
|
||||
phpstan:
|
||||
enabled: false
|
||||
fbinfer:
|
||||
enabled: false
|
||||
presidio:
|
||||
enabled: false
|
||||
biome:
|
||||
enabled: false # coderabbit uses our repo config and they're using old biome versions, which will fail.
|
||||
knowledge_base:
|
||||
web_search:
|
||||
enabled: true
|
||||
chat:
|
||||
auto_reply: true
|
||||
art: false
|
||||
@@ -1,11 +1,10 @@
|
||||
{
|
||||
"name": "filebrowser",
|
||||
"image": "mcr.microsoft.com/devcontainers/go:1.25-bookworm",
|
||||
|
||||
"image": "mcr.microsoft.com/devcontainers/go:1-trixie",
|
||||
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/node:1": {
|
||||
"version": "22"
|
||||
"version": "26"
|
||||
},
|
||||
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
|
||||
},
|
||||
@@ -30,10 +29,12 @@
|
||||
"extensions": [
|
||||
"golang.go",
|
||||
"Vue.volar",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"esbenp.prettier-vscode",
|
||||
"biomejs.biome",
|
||||
"ms-azuretools.vscode-docker"
|
||||
]
|
||||
],
|
||||
"settings": {
|
||||
"biome.enabled": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -9,9 +9,10 @@ backend/filebrowser.sqlite*
|
||||
backend/tmp
|
||||
backend/dist
|
||||
backend/backend*
|
||||
backend/internal/web/dist/**
|
||||
backend/vendor/**
|
||||
backend/internal/web/dist/*
|
||||
!backend/internal/web/dist/.gitkeep
|
||||
|
||||
|
||||
frontend/dist/**
|
||||
frontend/node_modules/**
|
||||
frontend/pkg/**
|
||||
@@ -0,0 +1,90 @@
|
||||
#!/usr/bin/env bash
|
||||
# Builds the comma-separated Docker tag list for a release image.
|
||||
#
|
||||
# Usage: docker-release-tags.sh <metadata.json> <variant> <update_track> <update_major>
|
||||
# metadata.json JSON output of docker/metadata-action (uses .tags)
|
||||
# variant default | slim | gpu
|
||||
# default and gpu: floating tags include latest
|
||||
# slim: every tag gets a -slim suffix and latest is not added
|
||||
# update_track true when the semver policy allows floating beta/stable/latest tags
|
||||
# update_major true when the semver policy allows major-only version tags
|
||||
#
|
||||
# Image repositories are fixed per variant so that each image only gets its own tags.
|
||||
set -euo pipefail
|
||||
|
||||
if [[ $# -ne 4 ]]; then
|
||||
echo "usage: $0 <metadata.json> <default|slim|gpu> <true|false> <true|false>" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
metadata_file=$1
|
||||
variant=$2
|
||||
update_track=$3
|
||||
update_major=$4
|
||||
|
||||
case "$variant" in
|
||||
default)
|
||||
suffix=""
|
||||
add_latest=true
|
||||
repos=(gtstef/filebrowser ghcr.io/gtsteffaniak/filebrowser)
|
||||
;;
|
||||
slim)
|
||||
suffix="-slim"
|
||||
add_latest=false
|
||||
repos=(gtstef/filebrowser ghcr.io/gtsteffaniak/filebrowser)
|
||||
;;
|
||||
gpu)
|
||||
suffix=""
|
||||
add_latest=true
|
||||
repos=(gtstef/filebrowser-gpu ghcr.io/gtsteffaniak/filebrowser-gpu)
|
||||
;;
|
||||
*)
|
||||
echo "unknown variant: $variant" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
jq -r \
|
||||
--arg suffix "$suffix" \
|
||||
--argjson addLatest "$add_latest" \
|
||||
--argjson updateTrack "$update_track" \
|
||||
--argjson updateMajor "$update_major" \
|
||||
--arg dh "${repos[0]}" \
|
||||
--arg gh "${repos[1]}" '
|
||||
# Strip the v prefix, drop metadata latest, and append the variant suffix.
|
||||
.tags |= map(
|
||||
sub(":v"; ":")
|
||||
| select(test(":latest") | not)
|
||||
| . + $suffix
|
||||
) |
|
||||
# Version tags with a prerelease suffix (X.Y.Z-suffix) get major.minor, and major when allowed.
|
||||
.tags += [
|
||||
.tags[]
|
||||
| select(test(":[0-9]+\\.[0-9]+\\.[0-9]+-"))
|
||||
| split(":")
|
||||
| .[-1] as $version
|
||||
| ($version | split("-")) as $version_split
|
||||
| ($version_split[0] | split(".")) as $version_parts
|
||||
| ($version_split[1:] | join("-")) as $tag_suffix
|
||||
| ($version_parts | "\(.[0]).\(.[1])") as $major_minor
|
||||
| ($version_parts[0]) as $major
|
||||
| "\($dh):\($major_minor)-\($tag_suffix)",
|
||||
"\($gh):\($major_minor)-\($tag_suffix)",
|
||||
if $updateMajor then
|
||||
"\($dh):\($major)-\($tag_suffix)",
|
||||
"\($gh):\($major)-\($tag_suffix)"
|
||||
else empty end
|
||||
] |
|
||||
# Floating beta tag.
|
||||
if $updateTrack and any(.tags[]; split(":")[-1] | endswith("-beta" + $suffix)) then
|
||||
.tags += ["\($dh):beta\($suffix)", "\($gh):beta\($suffix)"]
|
||||
else . end |
|
||||
# Floating stable tag, plus latest for variants that have it.
|
||||
if $updateTrack and any(.tags[]; split(":")[-1] | endswith("-stable" + $suffix)) then
|
||||
.tags += (
|
||||
["\($dh):stable\($suffix)", "\($gh):stable\($suffix)"]
|
||||
+ (if $addLatest then ["\($dh):latest", "\($gh):latest"] else [] end)
|
||||
)
|
||||
else . end |
|
||||
.tags | join(",")
|
||||
' "$metadata_file"
|
||||
@@ -15,7 +15,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
token: ${{ secrets.PAT }} # Uses the Personal Access Token
|
||||
|
||||
|
||||
@@ -14,23 +14,23 @@ jobs:
|
||||
runs-on: ubuntu-24.04-arm
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v7
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3.0.0
|
||||
uses: docker/setup-qemu-action@v4
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3.0.0
|
||||
- uses: actions/setup-node@v4
|
||||
uses: docker/setup-buildx-action@v4
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version-file: frontend/.nvmrc
|
||||
- working-directory: frontend
|
||||
run: npm i && npm run build
|
||||
- uses: actions/setup-go@v5
|
||||
run: npm ci && npm run build
|
||||
- uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: 'stable'
|
||||
- working-directory: backend
|
||||
run: go build -o filebrowser .
|
||||
- name: Build
|
||||
uses: docker/build-push-action@v6
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
context: .
|
||||
file: ./_docker/Dockerfile.playwright-general
|
||||
|
||||
+50
-27
@@ -14,11 +14,11 @@ jobs:
|
||||
runs-on: ubuntu-24.04-arm
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v7
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
uses: docker/setup-buildx-action@v4
|
||||
- name: Prime Cache
|
||||
uses: docker/build-push-action@v6
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
context: .
|
||||
file: _docker/Dockerfile.primecache
|
||||
@@ -31,32 +31,32 @@ jobs:
|
||||
runs-on: ubuntu-24.04-arm
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
uses: actions/checkout@v7
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version-file: frontend/.nvmrc
|
||||
- name: Build frontend
|
||||
working-directory: frontend
|
||||
run: npm i && npm run build
|
||||
run: npm ci && npm run build
|
||||
- name: Upload frontend build artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: dist
|
||||
path: backend/internal/web/dist
|
||||
path: frontend/dist
|
||||
build_backend:
|
||||
name: Build backend
|
||||
runs-on: ubuntu-24.04-arm
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
uses: actions/checkout@v7
|
||||
- uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: 'stable'
|
||||
- name: Build backend
|
||||
working-directory: backend
|
||||
run: go build -o filebrowser .
|
||||
- name: Upload backend build artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: filebrowser
|
||||
path: backend/filebrowser
|
||||
@@ -92,30 +92,26 @@ jobs:
|
||||
dockerfile: ./_docker/Dockerfile.playwright-performance
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v7
|
||||
- name: Download frontend build
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: dist
|
||||
path: frontend/dist
|
||||
- name: Download backend build
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: filebrowser
|
||||
path: backend/
|
||||
- name: Make backend executable
|
||||
run: chmod +x backend/filebrowser
|
||||
- name: Copy frontend build to backend
|
||||
run: |
|
||||
mkdir -p backend/internal/web/embed
|
||||
cp -r frontend/dist/* backend/internal/web/embed
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3.0.0
|
||||
uses: docker/setup-qemu-action@v4
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3.0.0
|
||||
uses: docker/setup-buildx-action@v4
|
||||
- name: Build and Test
|
||||
id: build
|
||||
uses: docker/build-push-action@v6
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
context: .
|
||||
file: ${{ matrix.dockerfile }}
|
||||
@@ -135,7 +131,7 @@ jobs:
|
||||
docker rm "$cid"
|
||||
- name: Upload listing performance results
|
||||
if: matrix.name == 'performance' && success()
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: listing-performance-results
|
||||
path: perf-artifact/results.json
|
||||
@@ -145,16 +141,16 @@ jobs:
|
||||
runs-on: ubuntu-24.04-arm
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v7
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3.0.0
|
||||
uses: docker/setup-qemu-action@v4
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3.0.0
|
||||
uses: docker/setup-buildx-action@v4
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: docker/metadata-action@v6
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
context: .
|
||||
file: ./_docker/Dockerfile.slim
|
||||
@@ -166,3 +162,30 @@ jobs:
|
||||
REVISION=${{ steps.meta.outputs.revision }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
build_gpu_docker_image:
|
||||
name: Build gpu docker image
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v4
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v6
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
context: .
|
||||
file: ./_docker/Dockerfile.gpu
|
||||
push: false # Do not push the image for now
|
||||
load: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
build-args: |
|
||||
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
|
||||
REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
|
||||
cache-from: type=gha,scope=pr-gpu
|
||||
# Cache export is best-effort; flaky GHA cache (503) must not fail a green build.
|
||||
cache-to: type=gha,mode=max,scope=pr-gpu,ignore-error=true
|
||||
@@ -15,7 +15,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
token: ${{ secrets.PAT }} # Uses the Personal Access Token
|
||||
|
||||
|
||||
@@ -10,18 +10,20 @@ jobs:
|
||||
runs-on: ubuntu-24.04-arm
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: 'stable'
|
||||
- name: Install ffmpeg
|
||||
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends ffmpeg
|
||||
- working-directory: backend
|
||||
run: go test -race -v ./... -timeout 30s
|
||||
run: go test -race ./... -timeout 45s
|
||||
lint-backend:
|
||||
runs-on: ubuntu-24.04-arm
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: 'stable'
|
||||
- name: Lint backend
|
||||
@@ -32,8 +34,8 @@ jobs:
|
||||
runs-on: ubuntu-24.04-arm
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: 'stable'
|
||||
- working-directory: backend
|
||||
@@ -42,38 +44,48 @@ jobs:
|
||||
runs-on: ubuntu-24.04-arm
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version-file: frontend/.nvmrc
|
||||
- working-directory: frontend
|
||||
run: npm i && npm run lint
|
||||
run: npm ci && npm run lint
|
||||
test-frontend:
|
||||
runs-on: ubuntu-24.04-arm
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version-file: frontend/.nvmrc
|
||||
- working-directory: frontend
|
||||
run: npm i && npm run test
|
||||
run: npm ci && npm run test
|
||||
typecheck-frontend:
|
||||
runs-on: ubuntu-24.04-arm
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version-file: frontend/.nvmrc
|
||||
- working-directory: frontend
|
||||
run: npm ci && npm run typecheck
|
||||
check-translations:
|
||||
runs-on: ubuntu-24.04-arm
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version-file: frontend/.nvmrc
|
||||
- working-directory: frontend
|
||||
run: npm i && npm run i18n:check
|
||||
run: npm ci && npm run i18n:check
|
||||
check-docs:
|
||||
runs-on: ubuntu-24.04-arm
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: 'stable'
|
||||
- run: make generate-docs
|
||||
@@ -82,9 +94,9 @@ jobs:
|
||||
runs-on: ubuntu-24.04-arm
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version-file: frontend/.nvmrc
|
||||
- working-directory: frontend
|
||||
run: npm i && npm run icons:check
|
||||
run: npm ci && npm run icons:check
|
||||
+89
-109
@@ -14,19 +14,23 @@ jobs:
|
||||
runs-on: ubuntu-24.04-arm
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v7
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version-file: backend/go.mod
|
||||
cache-dependency-path: backend/go.sum
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version-file: frontend/.nvmrc
|
||||
cache: npm
|
||||
cache-dependency-path: frontend/package-lock.json
|
||||
- name: Install dependencies and build frontend
|
||||
run: npm i && npm run build
|
||||
run: npm ci && npm run build
|
||||
working-directory: frontend
|
||||
- name: Install OS Requirements
|
||||
run: sudo apt update && sudo apt install -y upx build-essential musl-tools
|
||||
- uses: goto-bus-stop/setup-zig@v2
|
||||
- name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@v6
|
||||
uses: goreleaser/goreleaser-action@v7
|
||||
with:
|
||||
args: release --clean
|
||||
workdir: backend
|
||||
@@ -38,25 +42,25 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v7
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3.0.0
|
||||
uses: docker/setup-qemu-action@v4
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3.0.0
|
||||
uses: docker/setup-buildx-action@v4
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{github.actor}}
|
||||
password: ${{ secrets.PAT }}
|
||||
- name: Extract metadata (tags, labels) for Docker and GHCR
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: docker/metadata-action@v6
|
||||
with:
|
||||
images: |
|
||||
gtstef/filebrowser
|
||||
@@ -68,53 +72,11 @@ jobs:
|
||||
id: modify-json
|
||||
run: |
|
||||
JSON='${{ steps.meta.outputs.json }}'
|
||||
MODIFIED_JSON=$(echo "$JSON" | jq \
|
||||
--argjson updateTrack '${{ steps.floating.outputs.update_track == 'true' }}' \
|
||||
--argjson updateMajor '${{ steps.floating.outputs.update_major == 'true' }}' '
|
||||
.tags |= map(
|
||||
sub(":v"; ":") # Strip the 'v'
|
||||
| select(test(":latest") | not)
|
||||
) |
|
||||
# Find all version tags with suffix (X.Y.Z-suffix) and add major.minor (always) and major tags (when allowed)
|
||||
.tags += [
|
||||
.tags[]
|
||||
| select(test(":[0-9]+\\.[0-9]+\\.[0-9]+-"))
|
||||
| split(":")
|
||||
| .[-1] as $version
|
||||
| ($version | split("-")) as $version_split
|
||||
| ($version_split[0] | split(".")) as $version_parts
|
||||
| ($version_split[1:] | join("-")) as $suffix
|
||||
| ($version_parts | "\(.[0]).\(.[1])") as $major_minor
|
||||
| ($version_parts[0]) as $major
|
||||
| "gtstef/filebrowser:\($major_minor)-\($suffix)",
|
||||
"ghcr.io/gtsteffaniak/filebrowser:\($major_minor)-\($suffix)",
|
||||
if $updateMajor then
|
||||
"gtstef/filebrowser:\($major)-\($suffix)",
|
||||
"ghcr.io/gtsteffaniak/filebrowser:\($major)-\($suffix)"
|
||||
else empty end
|
||||
] |
|
||||
# Add suffix-only tags for beta when semver policy allows
|
||||
if $updateTrack and any(.tags[]; split(":")[-1] | endswith("-beta")) then
|
||||
.tags += [
|
||||
"gtstef/filebrowser:beta",
|
||||
"ghcr.io/gtsteffaniak/filebrowser:beta"
|
||||
]
|
||||
else . end |
|
||||
# Add suffix-only tags for stable (and latest) when semver policy allows
|
||||
if $updateTrack and any(.tags[]; split(":")[-1] | endswith("-stable")) then
|
||||
.tags += [
|
||||
"gtstef/filebrowser:stable",
|
||||
"ghcr.io/gtsteffaniak/filebrowser:stable",
|
||||
"gtstef/filebrowser:latest",
|
||||
"ghcr.io/gtsteffaniak/filebrowser:latest"
|
||||
]
|
||||
else . end
|
||||
')
|
||||
TAGS_CSV=$(echo "$MODIFIED_JSON" | jq -r '.tags | join(",")')
|
||||
echo "$TAGS_CSV" > modified_tags.txt # Optional debug output
|
||||
printf '%s' "$JSON" > metadata.json
|
||||
TAGS_CSV=$(bash .github/scripts/docker-release-tags.sh metadata.json default '${{ steps.floating.outputs.update_track }}' '${{ steps.floating.outputs.update_major }}')
|
||||
echo "cleaned_tag=$TAGS_CSV" >> $GITHUB_OUTPUT
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
context: .
|
||||
build-args: |
|
||||
@@ -125,30 +87,86 @@ jobs:
|
||||
push: true
|
||||
tags: ${{ steps.modify-json.outputs.cleaned_tag }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
push_slim_release_to_registry:
|
||||
name: Push slim release
|
||||
cache-from: type=gha,scope=release-main
|
||||
cache-to: type=gha,mode=max,scope=release-main
|
||||
push_gpu_release_to_registry:
|
||||
name: Push gpu release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v7
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3.0.0
|
||||
uses: docker/setup-qemu-action@v4
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3.0.0
|
||||
uses: docker/setup-buildx-action@v4
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{github.actor}}
|
||||
password: ${{ secrets.PAT }}
|
||||
- name: Extract metadata (tags, labels) for Docker and GHCR
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: docker/metadata-action@v6
|
||||
with:
|
||||
images: |
|
||||
gtstef/filebrowser-gpu
|
||||
ghcr.io/gtsteffaniak/filebrowser-gpu
|
||||
- name: Decide floating Docker tags
|
||||
id: floating
|
||||
env:
|
||||
IMAGE_REPO: gtstef/filebrowser-gpu
|
||||
run: bash .github/scripts/docker-floating-tag-policy.sh
|
||||
- name: Modify tags (strip 'v' and add version tags)
|
||||
id: modify-json
|
||||
run: |
|
||||
JSON='${{ steps.meta.outputs.json }}'
|
||||
printf '%s' "$JSON" > metadata.json
|
||||
TAGS_CSV=$(bash .github/scripts/docker-release-tags.sh metadata.json gpu '${{ steps.floating.outputs.update_track }}' '${{ steps.floating.outputs.update_major }}')
|
||||
echo "cleaned_tag=$TAGS_CSV" >> $GITHUB_OUTPUT
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
context: .
|
||||
build-args: |
|
||||
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
|
||||
REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
|
||||
platforms: linux/amd64
|
||||
file: ./_docker/Dockerfile.gpu
|
||||
push: true
|
||||
tags: ${{ steps.modify-json.outputs.cleaned_tag }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha,scope=release-gpu
|
||||
cache-to: type=gha,mode=max,scope=release-gpu,ignore-error=true
|
||||
push_slim_release_to_registry:
|
||||
name: Push slim release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v4
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v4
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{github.actor}}
|
||||
password: ${{ secrets.PAT }}
|
||||
- name: Extract metadata (tags, labels) for Docker and GHCR
|
||||
id: meta
|
||||
uses: docker/metadata-action@v6
|
||||
with:
|
||||
images: |
|
||||
gtstef/filebrowser
|
||||
@@ -162,51 +180,11 @@ jobs:
|
||||
id: modify-json-slim
|
||||
run: |
|
||||
JSON='${{ steps.meta.outputs.json }}'
|
||||
MODIFIED_JSON=$(echo "$JSON" | jq \
|
||||
--argjson updateTrack '${{ steps.floating.outputs.update_track == 'true' }}' \
|
||||
--argjson updateMajor '${{ steps.floating.outputs.update_major == 'true' }}' '
|
||||
.tags |= map(
|
||||
sub(":v"; ":") # Strip the 'v'
|
||||
| select(test(":latest") | not) # Remove the "latest" tag
|
||||
| . + "-slim" # Append "-slim" to the versioned tag
|
||||
) |
|
||||
# Find all version tags with suffix (X.Y.Z-suffix-slim) and add major.minor (always) and major tags (when allowed)
|
||||
.tags += [
|
||||
.tags[]
|
||||
| select(test(":[0-9]+\\.[0-9]+\\.[0-9]+-"))
|
||||
| split(":")
|
||||
| .[-1] as $version
|
||||
| ($version | split("-")) as $version_split
|
||||
| ($version_split[0] | split(".")) as $version_parts
|
||||
| ($version_split[1:] | join("-")) as $suffix
|
||||
| ($version_parts | "\(.[0]).\(.[1])") as $major_minor
|
||||
| ($version_parts[0]) as $major
|
||||
| "gtstef/filebrowser:\($major_minor)-\($suffix)",
|
||||
"ghcr.io/gtsteffaniak/filebrowser:\($major_minor)-\($suffix)",
|
||||
if $updateMajor then
|
||||
"gtstef/filebrowser:\($major)-\($suffix)",
|
||||
"ghcr.io/gtsteffaniak/filebrowser:\($major)-\($suffix)"
|
||||
else empty end
|
||||
] |
|
||||
# Add suffix-only tags for beta-slim when semver policy allows
|
||||
if $updateTrack and any(.tags[]; split(":")[-1] | endswith("-beta-slim")) then
|
||||
.tags += [
|
||||
"gtstef/filebrowser:beta-slim",
|
||||
"ghcr.io/gtsteffaniak/filebrowser:beta-slim"
|
||||
]
|
||||
else . end |
|
||||
# Add suffix-only tags for stable-slim when semver policy allows
|
||||
if $updateTrack and any(.tags[]; split(":")[-1] | endswith("-stable-slim")) then
|
||||
.tags += [
|
||||
"gtstef/filebrowser:stable-slim",
|
||||
"ghcr.io/gtsteffaniak/filebrowser:stable-slim"
|
||||
]
|
||||
else . end
|
||||
')
|
||||
TAGS_CSV=$(echo "$MODIFIED_JSON" | jq -r '.tags | join(",")')
|
||||
printf '%s' "$JSON" > metadata.json
|
||||
TAGS_CSV=$(bash .github/scripts/docker-release-tags.sh metadata.json slim '${{ steps.floating.outputs.update_track }}' '${{ steps.floating.outputs.update_major }}')
|
||||
echo "cleaned_tag=$TAGS_CSV" >> $GITHUB_OUTPUT
|
||||
- name: Build and push slim image
|
||||
uses: docker/build-push-action@v6
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
context: .
|
||||
build-args: |
|
||||
@@ -217,3 +195,5 @@ jobs:
|
||||
push: true
|
||||
tags: ${{ steps.modify-json-slim.outputs.cleaned_tag }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha,scope=release-slim
|
||||
cache-to: type=gha,mode=max,scope=release-slim
|
||||
@@ -13,23 +13,23 @@ jobs:
|
||||
packages: write
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v7
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
uses: docker/setup-buildx-action@v4
|
||||
- name: Log in to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: docker/metadata-action@v6
|
||||
with:
|
||||
images: ghcr.io/gtsteffaniak/playwright-base
|
||||
tags: chromium
|
||||
- name: Build and push playwright-base
|
||||
uses: docker/build-push-action@v6
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64
|
||||
@@ -38,4 +38,23 @@ jobs:
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha,scope=playwright-base
|
||||
cache-to: type=gha,mode=max,scope=playwright-base
|
||||
cache-to: type=gha,mode=max,scope=playwright-base
|
||||
- name: Extract metadata (tags, labels) for Docker (latest)
|
||||
id: meta_latest
|
||||
uses: docker/metadata-action@v6
|
||||
with:
|
||||
images: ghcr.io/gtsteffaniak/playwright-base
|
||||
tags: latest
|
||||
- name: Build and push playwright-base (Firefox)
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64
|
||||
file: _docker/Dockerfile.playwright-base
|
||||
push: true
|
||||
build-args: |
|
||||
PLAYWRIGHT_BROWSERS=chromium-headless-shell firefox
|
||||
tags: ${{ steps.meta_latest.outputs.tags }}
|
||||
labels: ${{ steps.meta_latest.outputs.labels }}
|
||||
cache-from: type=gha,scope=playwright-base-latest
|
||||
cache-to: type=gha,mode=max,scope=playwright-base-latest
|
||||
+2
-2
@@ -43,8 +43,8 @@ frontend/.tmp-icons-*
|
||||
/backend/*test_config.yaml
|
||||
/backend/generated.yaml
|
||||
/backend/srv
|
||||
/backend/internal/web/dist
|
||||
/backend/internal/web/embed
|
||||
/backend/internal/web/dist/*
|
||||
!/backend/internal/web/dist/.gitkeep
|
||||
/backend/debug
|
||||
/backend/http
|
||||
|
||||
|
||||
+95
-1
@@ -2,6 +2,100 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. For commit guidelines, please refer to [Standard Version](https://github.com/conventional-changelog/standard-version).
|
||||
|
||||
## v2.2.0
|
||||
|
||||
**New Features**:
|
||||
- Media enhancements
|
||||
- All server media settings can be managed in settings by admins.
|
||||
- JXL image preview support (#3334) (#2551)
|
||||
- Transcoding for media playback with quality presets (requires ffmpeg).
|
||||
- Hardware Acceleration device selector (Software / detected GPU devices)
|
||||
- More operations use native api operations rather than ffmpeg, improving performance in many cases. Added temporary config option to force ffmpeg to be used..
|
||||
- HLS keyframe indexes for MP4/MOV/M4V/MKV/WebM are read from the container index with go-media instead of demuxing every packet with ffprobe; ffprobe still runs when go-media cannot read the file or reports a keyframe gap that would rule out stream copy.
|
||||
- HEIC/AVIF rotation (irot) for the ffmpeg decode fallback is read with go-media instead of a full `ffmpeg -f null` decode.
|
||||
- AVIF images get previews through the HEIC preview path (go-media decode, ffmpeg fallback) when HEIC previews are enabled.
|
||||
- WMV/ASF video thumbnails use go-media for WMV3; WMV1/WMV2 still use ffmpeg.
|
||||
- ffmpeg and go-media share one media metadata cache keyed by path, size and modification time, so a probe, duration or subtitle result from either backend is reused by the other.
|
||||
- Preview cache keys use a faster, non-cryptographic xxHash instead of MD5. When upgrading from a version older than v2.2.0, the preview and thumbnail cache is cleared once at startup and previews regenerate on demand. The index database is not affected.
|
||||
- Camera RAW previews use the largest embedded JPEG that fits the decode size limit. Some Nikon NEF files, whose full-size JPEG exceeded the limit, previously showed no preview.
|
||||
- Original-size previews of camera RAW files and other embedded images (JPEG, PNG, WebP) are returned as stored, without decoding, resizing, or re-encoding. Rotated JPEGs are still corrected for orientation.
|
||||
- HEIC/HEIF previews decode at the requested preview size for small and large previews instead of decoding full resolution, and the JPEG is encoded straight from the decoded YCbCr planes, which reduces CPU time and memory.
|
||||
- HEIC/HEIF files with extra bytes after the last valid container box (for example some Samsung files) now decode instead of failing.
|
||||
- HEIC/HEIF previews from the coded decode path convert limited-range YCbCr to full range before JPEG encoding.
|
||||
- Document enhancements
|
||||
- Official Collabora support using WOPI config.
|
||||
- Document previews use a pure-go in-process package (all versions get it now).
|
||||
- Added **Always use office for document previews** option to force OnlyOffice/Collabora.
|
||||
- Office previews can use embedded thumbnail if possible.
|
||||
- Text file previews are more efficient direct creation.
|
||||
- New text preview API (`/api/resources/preview/text`) returns a 16KB text preview for text, Markdown, HTML, CSS, code and RTF files. Markdown and HTML render in the listing as sanitized previews. Previews are not cached on disk. SVG files are served directly as images.
|
||||
- Text previews only render inline on tiles at least 60px wide, so narrower tiles (list, compact, normal) show the file-type icon with a `saved_search` badge instead when popup previews are enabled, and hovering still opens the larger popup preview. Text preview reads are bounded by the preview service's shared image-processor semaphore (`server.numImageProcessors`), and rendered preview HTML is cached in the browser so scrolling and hovering do not re-parse it.
|
||||
- Embedded previews for Krita (`.kra`, [#2431](https://github.com/gtsteffaniak/filebrowser/issues/2431)), OpenRaster (`.ora`), Sketch (`.sketch`), MuseScore (`.mscz`), CBZ (first page), XPS (embedded thumbnail, when present), ODF (`.odt`, `.ods`, `.odp`, `.odg`), and Office Open XML (`.docx`, `.xlsx`, `.pptx`) thumbnails.
|
||||
- Virtual scrolling for large lists: like the main listing, advanced search, file tree, etc. Only render the rows on screen, so very large folders stay responsive, resolving some performance issues (#2879) (#1773) (#3320) (#3326).
|
||||
- Search and navigation improvements:
|
||||
- Next/previous in a preview follows the results of quick search and advanced search, playback queue also uses if there's media (#3275).
|
||||
- Closing a preview opened from quick or advanced search returns to the results and scrolls to the item like the normal listing (#3275).
|
||||
- Advanced search now has almost all the features of the normal listing, including rectangle selection, keyboard navigation, etc (#3299).
|
||||
- Quick search results use natural ordering.
|
||||
- Optional FTS5 trigram index for faster name search via `server.indexSqlConfig.fts5: true` (default `false`; ~40% slower indexing and ~15% larger index DB). Quick search is debounced and cancels in-flight queries (#3146) (#3137).
|
||||
- Type, file, and date filters can run without a search term. There is no minimum query length; results are capped at 5,000 (#3445).
|
||||
- Listings now are cached (with a cap) allowing a more responsive navigation between folders (#3193).
|
||||
- File Info is tabbed (details, media, quota, access, checksums). The Media Info tab shows album, lyrics, subtitles, and tags; videos use embedded artwork as poster/session art, and MP4/M4V/MOV tags and cover art are read in the backend. Access rules can be edited from Info (#3364).
|
||||
- Right-click a breadcrumb for Info, copy page URL, copy WebDAV URL (when enabled), and copy path (#3428) (#3022).
|
||||
- Upload prompt shows overall progress for multi-file uploads: files done/total, failures, speed, and time remaining (#3399) (#3398) (#2340).
|
||||
- Upload and download prompts list is reversed (#2998) (#3328).
|
||||
- Theme preference is Follow system / Light / Dark. Follow system tracks the OS `prefers-color-scheme` live; legacy boolean `darkMode` still loads (#3297).
|
||||
- Replaced `indented soft wrap` editor setting by a dropdown with more wrap settings (#3183) (#3282).
|
||||
- Option in settings to prefer editor first for HTML files, matching the existing Markdown option (#3431) (#3363).
|
||||
- Finnish (Suomi) translation (#3400).
|
||||
- Specify custom share URI is possible when user account settings are enabled via `userDefaults.Account.allowCustomShareURL: true` (default `false`). default generated hash values for a share will still work after creating a custom one (#3416) (#3439) (#841).
|
||||
- Slideshow for images and videos in a folder, with duration, fade, fit/fill, shuffle, loop, Ken Burns, include subfolders (with a max-item cap), fullscreen, filename overlay, and play-videos-to-end (#3445) (#3339)
|
||||
|
||||
**Notes**:
|
||||
- Core web assets are loaded into memory instead of served from disk.
|
||||
- **Document preview formats:** New in-process support includes **`.azw3`**, **`.chm`**, **`.htm`**, and **`.html`**. However, `.doc` continues to require the office integration for thumbnails. **`.xps`** and **`.cbz`** previews come from embedded images. With **Always use office for document previews** enabled, office files still use the office converter
|
||||
- UPX compression is removed from release builds.
|
||||
- A `filebrowser-gpu` image is published alongside the main and slim images (amd64, hardware-accelerated ffmpeg).
|
||||
- Previews (thumbnails, popup, and text previews) are no longer requested for sources the user does not have view access to.
|
||||
- [docker] new filebrowser-gpu image for docker deployments with gpu devices available. Works for nvidia, AMD, Intel.
|
||||
- [docker] ffmpeg upgraded to version 9.1
|
||||
- [docker] filebrowser minimal image no longer published.
|
||||
- Admin-only Shadow Regressions viewer compares go-media vs ffmpeg preview outcomes during the v2.2.x beta; it is not intended for stable (#3414).
|
||||
|
||||
**Bug Fixes**:
|
||||
- Closing a video preview from the header bar now stops playback immediately instead of leaving audio running in the background.
|
||||
- Closing a preview no longer navigates back to the same file when a stale "previous item" was remembered from an earlier navigation.
|
||||
- Transcoding recovers from unreliable hardware decoding without discarding the segments already produced: the retry resumes at the encode head with software decode instead of wiping the generation and re-encoding from the start.
|
||||
- The player no longer aborts a segment request after 10 seconds while the transcode producer is repositioning or restarting, which previously surfaced as a 503 and a skipped segment.
|
||||
- getDirectoryPreview no longer requests metadata, so folder previews skip the per-file probe and subtitle scan.
|
||||
- Media probes are cached by file identity and concurrent reads are coalesced, so opening a file no longer triggers repeated ffprobe runs.
|
||||
- Client-initiated stream cancels (seek/navigation) no longer log spurious write-error responses.
|
||||
- Gzipped `.woff` font files are no longer generated without being served; only `.js` and `.woff2` are precompressed.
|
||||
- Album art detection during indexing walks container headers instead of scanning a fixed-size prefix. M4A/MP4 cover art is found wherever `moov` sits in the file, and M4A files without cover art no longer report a preview. MP3 (ID3v2.2-2.4), FLAC and Ogg Vorbis/Opus/FLAC detection now finds art after large frames, padding or long comments, within per-format scan limits (for example, at most 256 KiB of an unsynchronised ID3v2.3 tag is read). Pictures that only link to an image URL are not counted.
|
||||
- Ogg/Opus and Vorbis `METADATA_BLOCK_PICTURE` comments now use the same PICTURE parser as FLAC, so cover art with a MIME type or description — including images whose stored height is 0 — is detected, and empty picture data is not.
|
||||
- Text preview tiles no longer show the bottom truncation fade; truncated content is clipped at the tile edge instead.
|
||||
- Text preview tiles lay out at a minimum width and are clipped, instead of wrapping aggressively on narrow tiles.
|
||||
- Queued text preview requests are canceled when their tiles unmount, so scrolling through a folder of text files and then opening another folder no longer delays the new folder's previews.
|
||||
- Removed the stale, unreferenced `backend/internal/web/embed/` build output that was accidentally re-added; the frontend is embedded from `backend/internal/web/dist/` as before.
|
||||
- Advanced search no longer loses the previously selected sorting (#3275)
|
||||
- Context menu in iOS don't opening in Advanced Search (#2776) (#3299)
|
||||
- Improved mobile layout of inputs in search filters.
|
||||
- Doing actions in the main list/adv search, like move, copy, delete, or create a new file no longer reloads the entire listing, now updates in place and doesn't lost the position you were browsing at (#3193).
|
||||
- Uploading lot of files freezing the UI for a few seconds (#3321).
|
||||
- Directory uploads are prioritized, and files wait until their parent is ready (#3221).
|
||||
|
||||
## v2.1.6
|
||||
|
||||
**Security**:
|
||||
- [High] Archive extraction now bounds symlink target resolution under the extract destination and rejects absolute or `..` link text, including chained symlinks created during the same extract, closing a follow-up escape path related to GHSA-jg32-ppcc-ph62 (#3404) (#3384)
|
||||
|
||||
**Bug Fixes**:
|
||||
- fix(utils): `IsTextFile` reads only an 8KB sample instead of the whole file, avoiding excessive memory use when classifying large files for the editor, file watcher, and subtitle checks (#3405) (#3395)
|
||||
- fix(frontend): shows per-user scope quota (used vs cap) when a scope quota is configured (#3406) (#3402)
|
||||
- fix: custom themes apply immediately after login. (#3418) (#3375) (#2953)
|
||||
- fix: single-file downloads from shared items start without a format (#3420) (#3412)
|
||||
- fix: 3D model previews resolve related assets such as textures and material files from the same source, reusing the source-scoped token for all assets (#3423) (#3410)
|
||||
|
||||
## v2.1.5
|
||||
|
||||
**Security**:
|
||||
@@ -78,7 +172,7 @@ All notable changes to this project will be documented in this file. For commit
|
||||
- [Moderate] Authenticated `GET /api/resources/view` no longer accepts view tokens minted for a public share when the caller lacks view permission on the requested source (GHSA-wxj5-g3qp-g732) reporter @BlueN0r
|
||||
- [Low] SSE source-update and user-targeted delivery hold the client registry lock through nonblocking sends, preventing concurrent map mutation and send-on-closed-channel panics when Realtime clients connect, disconnect, or shut down (GHSA-p9wm-f5jj-75pj) reporter @tao0845
|
||||
- [High] Incomplete symlink-containment remediation: an authenticated non-admin user could create a relative symlink via archive extraction, relocate it with WebDAV MOVE, and write through it to arbitrary host paths with the service account's privileges (GHSA-3j46-5w28-f8p2) reporter @Saku0512
|
||||
- [Moderate] Source-root containment bypass: create, write, delete, and move operations now resolve symlinks uncached and enforce the caller's scope, closing API escapes through pre-existing out-of-source symlinks on upload, PUT, PATCH, delete, and WebDAV endpoints (GHSA-j764-qg3m-rhv7) reporter @chaoming0625
|
||||
- [Moderate] Source-root containment bypass: create, write, delete, and move operations now resolve symlinks uncached and enforce the caller's scope, closing escapes through pre-existing out-of-source symlinks on upload, PUT, PATCH, delete, and WebDAV endpoints (GHSA-j764-qg3m-rhv7) reporter @chaoming0625
|
||||
- [Moderate] Preview reads resolve symlinks within the caller's scope so authenticated preview cannot follow an out-of-scope symlink target (GHSA-g2q5-r6ch-v25f) reporter @tao0845
|
||||
- [Moderate] Archive downloads and extraction no longer read or write through symlinks that resolve outside the caller's share or user scope; escaping archive-walk entries are skipped (GHSA-qqf3-2wvq-q4w9) reporter @SmokinCaterpillar
|
||||
- [Moderate] Share directory-archive downloads now apply the share owner's access rules to every entry, closing a bypass where anonymous share visitors could download admin-denied content (GHSA-9fcr-gm58-p839) reporter @Tan-JunWei
|
||||
|
||||
+98
-33
@@ -4,8 +4,8 @@ Thank you for your interest in contributing to FileBrowser Quantum! This guide w
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- **Go 1.25+** (see `backend/go.mod`)
|
||||
- **Node.js 22.0.0+** with npm 9.0.0+ (see `frontend/package.json`)
|
||||
- **Go 1.27+** (see `backend/go.mod`)
|
||||
- **Node.js 26+** and **npm 11.20.0+** (see `frontend/package.json`)
|
||||
- **Docker** (optional, for containerized development)
|
||||
- **Git** especially important on Windows -- needed for bash support.
|
||||
|
||||
@@ -16,10 +16,7 @@ Thank you for your interest in contributing to FileBrowser Quantum! This guide w
|
||||
- macOS: `brew install ffmpeg`
|
||||
- Windows: Download from [ffmpeg.org](https://ffmpeg.org/download.html)
|
||||
|
||||
- **mupdf-tools**: For PDF preview generation
|
||||
- Ubuntu/Debian: `sudo apt-get install mupdf-tools`
|
||||
- macOS: `brew install mupdf-tools`
|
||||
- Windows: Download from [mupdf.com](https://mupdf.com/downloads/)
|
||||
Document thumbnails (PDF, EPUB, Office Open XML, and similar) are generated in-process via [folio](https://github.com/gen2brain/folio). An optional office integration is used as a fallback for formats folio does not handle and for in-browser editing.
|
||||
|
||||
## Quick Start
|
||||
|
||||
@@ -36,7 +33,8 @@ make dev
|
||||
```
|
||||
|
||||
`make setup` installs all dependencies and creates a test configuration file.
|
||||
`make run` starts the development server. Note: changes require ctrl+c and re-run.
|
||||
`make dev` runs the development server and Air together, so frontend and backend changes reload automatically.
|
||||
`make run` builds the frontend and starts the server once. Note: changes require ctrl+c and re-run.
|
||||
|
||||
## Project Architecture
|
||||
|
||||
@@ -48,35 +46,43 @@ make dev
|
||||
- **Indexing**: Real-time search in `backend/pkg/indexing/`
|
||||
- **Previews**: Image/video/document generation in `backend/internal/preview/`
|
||||
- **Activity**: Query, recording, and export logic in `backend/internal/activity/`
|
||||
- **Settings**: Configuration handling in `backend/pkg/settings/`
|
||||
- **API docs**: Swagger docs in `backend/swagger/`, generated by `make generate-docs`
|
||||
|
||||
### Frontend (Vue.js + TypeScript)
|
||||
- **Framework**: Vue 3 + Vite + TypeScript
|
||||
- **State**: Custom store in `frontend/src/store/`
|
||||
- **API Client**: Axios-based in `frontend/src/api/`
|
||||
- **i18n**: 25+ languages with English as main
|
||||
- **Components**: Feature-based organization
|
||||
- **Views and components**: `frontend/src/views/` (pages) and `frontend/src/components/` (feature-based), with shared logic in `frontend/src/composables/`
|
||||
- **i18n**: 25+ languages with English as the source locale, typed with generated types (see [Translations](#translations-i18n)).
|
||||
|
||||
## Development Commands
|
||||
|
||||
### Essential Commands
|
||||
```bash
|
||||
make dev # Start development server with hot-reloading
|
||||
make test # Run all tests
|
||||
make lint # Check code quality
|
||||
make check-all # Lint + tests
|
||||
|
||||
make dev # Start development server with hot-reloading
|
||||
make test # Run all tests
|
||||
make lint # Check code quality
|
||||
make check-all # Lint + tests
|
||||
make build-frontend # Build frontend only
|
||||
make build-backend # Build backend only
|
||||
make build # Build Docker image
|
||||
make build-backend # Build backend only (embeds the frontend build)
|
||||
make build # Build frontend and backend
|
||||
make build-docker # Build Docker image
|
||||
make generate-docs # Regenerate swagger docs
|
||||
```
|
||||
|
||||
### Frontend Development
|
||||
|
||||
Note: consider using make commands above instead.
|
||||
|
||||
```bash
|
||||
cd frontend
|
||||
npm run lint:fix # Auto-fix linting issues
|
||||
npm run i18n:sync # Sync translations changes
|
||||
npm run lint # Biome
|
||||
npm run i18n:check # i18n checks
|
||||
npm run lint:fix # Auto-fix Biome issues
|
||||
npm run typecheck # vue-tsc
|
||||
npm run test # Vitest
|
||||
npm run i18n:types # Regenerate i18n types
|
||||
```
|
||||
|
||||
## Testing
|
||||
@@ -89,7 +95,7 @@ make test-frontend # Frontend unit tests
|
||||
make test-playwright # E2E tests in Docker
|
||||
```
|
||||
|
||||
E2E tests run with three authentication modes: standard auth, no auth, and proxy auth.
|
||||
E2E tests are split into projects (for example `general`, `settings`, `sharing`, `noauth`, `jwt`, `proxy`, `oidc` and `previews`). `make test-playwright` runs all of them, and `PROJECT=<name>` runs only one.
|
||||
|
||||
## Code Standards
|
||||
|
||||
@@ -100,10 +106,52 @@ E2E tests run with three authentication modes: standard auth, no auth, and proxy
|
||||
- **Errors**: Handle all errors explicitly
|
||||
|
||||
### Frontend (Vue.js)
|
||||
- **Linting**: ESLint with Vue 3 + TypeScript rules
|
||||
- **i18n**: English is master locale, all text must use `$t('key')`
|
||||
- **Types**: Use TypeScript everywhere
|
||||
- **Fix**: Run `npm run lint:fix` before committing
|
||||
- **Linting**: [Biome](https://biomejs.dev/) (`frontend/biome.json`) and `vue-tsc` for type checking. `make lint-frontend` runs both plus the i18n checks.
|
||||
- **Components**: New components should use `<script setup lang="ts">`. We are currently migrating from the Options API.
|
||||
- **Types**: Use TypeScript for new code. Existent `.js` files are being migrated too.
|
||||
- **i18n**: All user-facing text goes through the typed `t()`, see below.
|
||||
- **Fix**: Run `npm run lint:fix` before committing.
|
||||
|
||||
### Translations
|
||||
|
||||
This only covers the basics, visit the [documentation page](https://filebrowserquantum.com/en/docs/contributing/translations/translations/) for more details.
|
||||
|
||||
`frontend/src/i18n/locales/en.json` is the master language. Types are generated from it into `frontend/src/i18n/messages.generated.ts`, so keys and `{placeholders}` are checked at compile time.
|
||||
|
||||
```ts
|
||||
import { useI18n } from "@/i18n/index.ts";
|
||||
|
||||
const { t } = useI18n();
|
||||
t("general.all");
|
||||
```
|
||||
|
||||
- Import `useI18n` from `@/i18n/index.ts`. In templates of `<script setup>` in vue files, use the same `t`.
|
||||
- Every key in `en.json` must be used somewhere in `src/`.
|
||||
- Use Strings literals and avoid using dynamic keys.
|
||||
|
||||
When changing a key in `en.json`:
|
||||
|
||||
```shell
|
||||
make generate-translation-types # regenerate messages.generated.ts
|
||||
make sync-translations # translates new keys in the other locales (needs DEEPL_API_KEY)
|
||||
make check-translations # run the i18n checks
|
||||
```
|
||||
|
||||
#### Contributing new translations
|
||||
|
||||
Language files are located at `frontend/src/i18n/locales`. The master language is `en.json` -- all other languages derive from this one.
|
||||
|
||||
To add a new language is very simple:
|
||||
|
||||
1. Create `frontend/src/i18n/locales/<your-locale>.json`, for example `es.json`. Start from a copy of `en.json`.
|
||||
2. Register it in `frontend/src/i18n/locales.ts`, in alphabetical order.
|
||||
|
||||
```ts
|
||||
// 'name': What to display in UI
|
||||
// 'file': The filename without extension
|
||||
// 'tag': BCP 47 matching navigator.language
|
||||
es: { name: 'Español', file: 'es', tag: 'es' }
|
||||
```
|
||||
|
||||
## Build & Deployment
|
||||
|
||||
@@ -117,7 +165,9 @@ make build-backend # Build Go binary with embedded assets
|
||||
|
||||
### Docker
|
||||
```bash
|
||||
make build # Full image with ffmpeg and muPDF
|
||||
make build-docker # Image with ffmpeg
|
||||
make build-docker-slim # Slim image
|
||||
make build-docker-gpu # GPU image (amd64, ffmpeg-gpu base)
|
||||
```
|
||||
|
||||
### Configuration
|
||||
@@ -125,21 +175,36 @@ make build # Full image with ffmpeg and muPDF
|
||||
|
||||
## Contributing
|
||||
|
||||
All changes go into `dev/vX.X.X` branches, so PRs must target one of them. For how `dev` branches are promoted to `beta` and `stable` releases, see the [Release Strategy](https://filebrowserquantum.com/en/docs/contributing/features/feature-development/#release-strategy).
|
||||
|
||||
The version in the name decides what the branch is for:
|
||||
|
||||
- Higher version (e.g. `dev/v2.2.0`): new features and big changes.
|
||||
- Lower version (e.g. `dev/v2.1.6`): bug fixes only.
|
||||
|
||||
Older `dev` branches may still exist but are no longer in use. Make sure you target the right one: the highest version for features, the newest lower version for bug fixes. Check the releases page to see the current `beta` version.
|
||||
|
||||
Always verify if the change you're about to submit exists already in one of the `dev/vX.X.X` branches to avoid duplicates.
|
||||
|
||||
### Pull Request Process
|
||||
|
||||
1. Fork and create a feature branch
|
||||
2. Make your changes following the code standards
|
||||
3. Run `make dev` to build and run with your changes. Supports hot-reloading frontend and backend changes.
|
||||
4. When ready, run `make check-all` to verify tests and linting
|
||||
5. Submit PR with a clear description
|
||||
1. Fork and create a feature branch from the matching `dev/vX.X.X` branch.
|
||||
2. Make your changes following the code standards.
|
||||
3. Run `make setup` and `make dev` to build and run with your changes. Supports hot-reloading frontend and backend changes.
|
||||
4. When ready, run `make check-all` to verify linting, tests, translations and icons. You can also run the Playwright tests locally with `make test-playwright`.
|
||||
5. Submit PR against the matching `dev/vX.X.X` branch with a clear description.
|
||||
|
||||
### PR Requirements
|
||||
- Clear description of changes
|
||||
- All tests must pass
|
||||
- Follow existing code patterns
|
||||
- Update documentation if needed
|
||||
- Clear description of changes.
|
||||
- All tests must pass.
|
||||
- Follow existing code patterns.
|
||||
- Update documentation if needed (see our [documentation](https://filebrowserquantum.com) and it's [repository](https://github.com/gtsteffaniak/filebrowserDocs)).
|
||||
- Regenerate generated files you affect (swagger docs, translation types, icons).
|
||||
|
||||
PRs are also reviewed automatically by CodeRabbit.
|
||||
|
||||
### Commit Format
|
||||
|
||||
```
|
||||
type(scope): description
|
||||
|
||||
|
||||
+9
-8
@@ -1,24 +1,25 @@
|
||||
FROM gtstef/ffmpeg:9.0.2-decode AS ffmpeg
|
||||
# syntax=docker/dockerfile:1.4
|
||||
FROM gtstef/ffmpeg:9.1 AS ffmpeg
|
||||
FROM golang:alpine AS base
|
||||
ARG VERSION
|
||||
ARG REVISION
|
||||
WORKDIR /app
|
||||
COPY ./backend/go.mod ./backend/go.sum ./
|
||||
RUN --mount=type=cache,target=/go/pkg/mod go mod download
|
||||
COPY ./backend ./
|
||||
RUN apk update && apk add --no-cache gcc musl-dev
|
||||
RUN go mod download && go run ./scripts/setup-gofitz-cgo
|
||||
ENV CGO_ENABLED=1
|
||||
RUN go build -tags analytics,mupdf,musl -ldflags="-w -s \
|
||||
ENV CGO_ENABLED=0
|
||||
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build go build -trimpath -tags analytics -ldflags="-w -s \
|
||||
-X 'github.com/gtsteffaniak/filebrowser/backend/internal/version.Version=${VERSION}' \
|
||||
-X 'github.com/gtsteffaniak/filebrowser/backend/internal/version.CommitSHA=${REVISION}'" \
|
||||
-o filebrowser .
|
||||
|
||||
FROM node:jod-slim AS nbuild
|
||||
FROM node:slim AS nbuild
|
||||
WORKDIR /build
|
||||
COPY ./frontend/package.json ./frontend/package-lock.json ./frontend/
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates \
|
||||
&& git config --global url."https://github.com/".insteadOf "git@github.com:" \
|
||||
&& git config --global url."https://github.com/".insteadOf "ssh://git@github.com/"
|
||||
RUN cd frontend && npm ci --maxsockets 1
|
||||
RUN --mount=type=cache,target=/root/.npm cd frontend && npm ci --maxsockets 1
|
||||
COPY ./frontend/ ./frontend/
|
||||
WORKDIR /build/frontend
|
||||
RUN npm run build:docker
|
||||
@@ -38,7 +39,7 @@ COPY --from=base --chown=filebrowser:1000 [ "/app/filebrowser", "./" ]
|
||||
COPY --from=base --chown=filebrowser:1000 [ "/app/config.yaml", "./data/config.yaml" ]
|
||||
COPY --from=base --chown=filebrowser:1000 [ "/app/config.yaml", "./" ]
|
||||
COPY --from=base --chown=filebrowser:1000 [ "/app/reduce-rounded-corners.css", "./" ]
|
||||
COPY --from=nbuild --chown=filebrowser:1000 [ "/build/backend/internal/web/dist/", "./internal/web/dist/" ]
|
||||
COPY --from=nbuild --chown=filebrowser:1000 [ "/build/frontend/dist/", "./internal/web/dist/" ]
|
||||
## sanity checks
|
||||
RUN [ "filebrowser", "version" ]
|
||||
RUN [ "ffmpeg", "-version" ]
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
# syntax=docker/dockerfile:1.4
|
||||
FROM golang:alpine AS base
|
||||
ARG VERSION
|
||||
ARG REVISION
|
||||
WORKDIR /app
|
||||
COPY ./backend/go.mod ./backend/go.sum ./
|
||||
RUN --mount=type=cache,target=/go/pkg/mod go mod download
|
||||
COPY ./backend ./
|
||||
ENV CGO_ENABLED=0
|
||||
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build go build -trimpath -tags analytics -ldflags="-w -s \
|
||||
-X 'github.com/gtsteffaniak/filebrowser/backend/internal/version.Version=${VERSION}' \
|
||||
-X 'github.com/gtsteffaniak/filebrowser/backend/internal/version.CommitSHA=${REVISION}'" \
|
||||
-o filebrowser .
|
||||
|
||||
FROM node:slim AS nbuild
|
||||
WORKDIR /build
|
||||
COPY ./frontend/package.json ./frontend/package-lock.json ./frontend/
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates
|
||||
RUN --mount=type=cache,target=/root/.npm cd frontend && npm ci --maxsockets 1
|
||||
COPY ./frontend/ ./frontend/
|
||||
WORKDIR /build/frontend
|
||||
RUN npm run build:docker
|
||||
|
||||
FROM alpine:latest
|
||||
ENV FILEBROWSER_DATABASE_PATH="/home/filebrowser/data/database.sqlite"
|
||||
ENV FILEBROWSER_CONFIG="/home/filebrowser/data/config.yaml"
|
||||
ENV PATH="$PATH:/home/filebrowser"
|
||||
RUN apk --no-cache add ca-certificates mailcap tzdata curl
|
||||
RUN adduser -D -s /bin/true -u 1000 filebrowser
|
||||
USER filebrowser
|
||||
WORKDIR /home/filebrowser
|
||||
# copy config to two locations for compatibility
|
||||
COPY --from=base --chown=filebrowser:1000 [ "/app/filebrowser", "./" ]
|
||||
COPY --from=base --chown=filebrowser:1000 [ "/app/config.yaml", "./data/config.yaml" ]
|
||||
COPY --from=base --chown=filebrowser:1000 [ "/app/config.yaml", "./" ]
|
||||
COPY --from=base --chown=filebrowser:1000 [ "/app/reduce-rounded-corners.css", "./" ]
|
||||
COPY --from=nbuild --chown=filebrowser:1000 [ "/build/frontend/dist/", "./internal/web/dist/" ]
|
||||
## sanity checks
|
||||
RUN [ "filebrowser", "version" ]
|
||||
# exposing default port for auto discovery.
|
||||
EXPOSE 80
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
||||
CMD curl -f http://localhost:80/health || exit 1
|
||||
ENTRYPOINT [ "./filebrowser" ]
|
||||
@@ -0,0 +1,70 @@
|
||||
# syntax=docker/dockerfile:1.4
|
||||
# GPU image (filebrowser-gpu) for linux/amd64 only.
|
||||
# Final base is gtstef/ffmpeg-gpu:<ver> (Debian trixie-slim runtime). That image already
|
||||
# ships ffmpeg/ffprobe in /usr/local/bin, the GPU userspace (VA-API, Vulkan, OpenCL, VPL),
|
||||
# and the codec shared libraries. This file only adds the filebrowser layer.
|
||||
|
||||
FROM golang:trixie AS base
|
||||
ARG VERSION
|
||||
ARG REVISION
|
||||
WORKDIR /app
|
||||
COPY ./backend/go.mod ./backend/go.sum ./
|
||||
RUN --mount=type=cache,target=/go/pkg/mod go mod download
|
||||
COPY ./backend ./
|
||||
ENV CGO_ENABLED=0
|
||||
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build go build -trimpath -tags analytics -ldflags="-w -s \
|
||||
-X 'github.com/gtsteffaniak/filebrowser/backend/internal/version.Version=${VERSION}' \
|
||||
-X 'github.com/gtsteffaniak/filebrowser/backend/internal/version.CommitSHA=${REVISION}'" \
|
||||
-o filebrowser .
|
||||
|
||||
FROM node:slim AS nbuild
|
||||
WORKDIR /build
|
||||
COPY ./frontend/package.json ./frontend/package-lock.json ./frontend/
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates
|
||||
RUN --mount=type=cache,target=/root/.npm cd frontend && npm ci --maxsockets 1
|
||||
COPY ./frontend/ ./frontend/
|
||||
WORKDIR /build/frontend
|
||||
RUN npm run build:docker
|
||||
|
||||
FROM gtstef/ffmpeg-gpu:9.1
|
||||
ENV FILEBROWSER_DATABASE_PATH="/home/filebrowser/data/database.sqlite"
|
||||
ENV FILEBROWSER_CONFIG="/home/filebrowser/data/config.yaml"
|
||||
ENV PATH="$PATH:/home/filebrowser"
|
||||
ENV NVIDIA_VISIBLE_DEVICES=all
|
||||
ENV NVIDIA_DRIVER_CAPABILITIES=compute,video,utility,graphics
|
||||
# curl is used by the healthcheck; the GPU runtime image does not ship it.
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends curl \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& useradd -m -u 1000 -s /usr/sbin/nologin filebrowser
|
||||
|
||||
USER filebrowser
|
||||
WORKDIR /home/filebrowser
|
||||
|
||||
COPY --from=base --chown=filebrowser:1000 [ "/app/filebrowser", "./" ]
|
||||
COPY --from=base --chown=filebrowser:1000 [ "/app/config.yaml", "./data/config.yaml" ]
|
||||
COPY --from=base --chown=filebrowser:1000 [ "/app/config.yaml", "./" ]
|
||||
COPY --from=base --chown=filebrowser:1000 [ "/app/reduce-rounded-corners.css", "./" ]
|
||||
COPY --from=nbuild --chown=filebrowser:1000 [ "/build/frontend/dist/", "./internal/web/dist/" ]
|
||||
|
||||
# Sanity checks: filebrowser and ffmpeg run, no missing shared libs, and the GPU
|
||||
# hwaccels/encoders/filters are compiled in. Mirrors scripts/check-gpu.sh in the ffmpeg repo.
|
||||
# These need no GPU device, so they run on CI runners.
|
||||
RUN filebrowser version && ffmpeg -version && ffprobe -version
|
||||
RUN ! ldd /usr/local/bin/ffmpeg | grep -q "not found"
|
||||
RUN ldd /usr/local/bin/ffmpeg | grep -q "libva.so" && ldd /usr/local/bin/ffmpeg | grep -q "libvpl.so"
|
||||
RUN ldconfig -p | grep -q libvulkan
|
||||
RUN ffmpeg -hide_banner -hwaccels | grep -q vaapi \
|
||||
&& ffmpeg -hide_banner -hwaccels | grep -q cuda \
|
||||
&& ffmpeg -hide_banner -hwaccels | grep -q vulkan
|
||||
RUN ffmpeg -hide_banner -encoders | grep -q h264_nvenc \
|
||||
&& ffmpeg -hide_banner -encoders | grep -q h264_vaapi \
|
||||
&& ffmpeg -hide_banner -encoders | grep -q h264_vulkan \
|
||||
&& ffmpeg -hide_banner -encoders | grep -q libx264 \
|
||||
&& ffmpeg -hide_banner -encoders | grep -q libvvenc
|
||||
RUN ffmpeg -hide_banner -filters | grep -q scale_vulkan \
|
||||
&& ffmpeg -hide_banner -filters | grep -q scale_vaapi
|
||||
|
||||
EXPOSE 80
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
||||
CMD curl -f http://localhost:80/health || exit 1
|
||||
ENTRYPOINT [ "./filebrowser" ]
|
||||
@@ -1,7 +1,8 @@
|
||||
FROM node:22-slim
|
||||
FROM node:26-slim
|
||||
WORKDIR /app/frontend
|
||||
|
||||
COPY frontend/package-lock.json /tmp/package-lock.json
|
||||
RUN PW_VERSION=$(node -p "require('/tmp/package-lock.json').packages['node_modules/@playwright/test'].version") \
|
||||
&& npm i "@playwright/test@${PW_VERSION}" oauth2-mock-server @types/node
|
||||
RUN npx playwright install --with-deps chromium-headless-shell
|
||||
ARG PLAYWRIGHT_BROWSERS="chromium-headless-shell"
|
||||
RUN npx playwright install --with-deps ${PLAYWRIGHT_BROWSERS}
|
||||
@@ -12,7 +12,7 @@ WORKDIR /app/backend/
|
||||
COPY [ "./backend/filebrowser", "./"]
|
||||
COPY [ "./backend/reduce-rounded-corners.css", "./no-rounded.css" ]
|
||||
RUN mkdir -p ./internal/web/dist
|
||||
COPY [ "./backend/internal/web/embed/", "./internal/web/dist/"]
|
||||
COPY [ "./frontend/dist/", "./internal/web/dist/"]
|
||||
|
||||
# generate duplicate 1.1MB files
|
||||
RUN dd if=/dev/zero of=/app/frontend/tests/playwright-files/1.1MB.bin bs=1024 count=1126 && dd if=/dev/zero of=/app/frontend/tests/playwright-files/1.1mb.bin bs=1024 count=1126
|
||||
|
||||
@@ -6,7 +6,7 @@ COPY [ "./frontend/tests", "./tests" ]
|
||||
WORKDIR /app/backend/
|
||||
COPY [ "./backend/filebrowser", "./"]
|
||||
RUN mkdir -p ./internal/web/dist
|
||||
COPY [ "./backend/internal/web/embed/", "./internal/web/dist/"]
|
||||
COPY [ "./frontend/dist/", "./internal/web/dist/"]
|
||||
RUN apt update && apt install nginx -y
|
||||
RUN mv default.conf /etc/nginx/conf.d/default.conf
|
||||
RUN sed -i 's/filebrowser/localhost/g' /etc/nginx/conf.d/default.conf
|
||||
|
||||
@@ -11,7 +11,7 @@ COPY [ "./_docker/src/settings/backend/config.yaml", "./"]
|
||||
COPY [ "./_docker/src/settings/backend/database.db.old", "./"]
|
||||
COPY [ "./backend/reduce-rounded-corners.css", "./no-rounded.css"]
|
||||
RUN mkdir -p ./internal/web/dist
|
||||
COPY [ "./backend/internal/web/embed/", "./internal/web/dist/"]
|
||||
COPY [ "./frontend/dist/", "./internal/web/dist/"]
|
||||
|
||||
ENV FILEBROWSER_PLAYWRIGHT_TEST=true
|
||||
RUN ./filebrowser user set testuser1 --password testuser1
|
||||
|
||||
@@ -11,7 +11,7 @@ COPY [ "./frontend/tests/", "./tests" ]
|
||||
WORKDIR /app/backend/
|
||||
COPY [ "./backend/filebrowser", "./"]
|
||||
RUN mkdir -p ./internal/web/dist
|
||||
COPY [ "./backend/internal/web/embed/", "./internal/web/dist/"]
|
||||
COPY [ "./frontend/dist/", "./internal/web/dist/"]
|
||||
|
||||
# Run tests
|
||||
ENV FILEBROWSER_PLAYWRIGHT_TEST=true
|
||||
|
||||
@@ -11,7 +11,7 @@ COPY [ "./frontend/tests/playwright-files", "./tests/playwright-files2" ]
|
||||
WORKDIR /app/backend/
|
||||
COPY [ "./backend/filebrowser", "./"]
|
||||
RUN mkdir -p ./internal/web/dist
|
||||
COPY [ "./backend/internal/web/embed/", "./internal/web/dist/"]
|
||||
COPY [ "./frontend/dist/", "./internal/web/dist/"]
|
||||
|
||||
# Run tests
|
||||
ENV FILEBROWSER_PLAYWRIGHT_TEST=true
|
||||
|
||||
@@ -7,7 +7,7 @@ WORKDIR /app/backend/
|
||||
RUN mkdir -p ./internal/web/dist
|
||||
COPY [ "./_docker/src/oidc/backend/", "./"]
|
||||
COPY ["./backend/filebrowser", "./"]
|
||||
COPY [ "./backend/internal/web/embed/", "./internal/web/dist/"]
|
||||
COPY [ "./frontend/dist/", "./internal/web/dist/"]
|
||||
|
||||
# Run tests
|
||||
WORKDIR /app/frontend
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Local listing-performance only (see docker-compose local-playwright-performance).
|
||||
# CI uses ghcr.io/gtsteffaniak/playwright-base:chromium + Dockerfile.playwright-performance.
|
||||
FROM node:22-slim
|
||||
FROM node:26-slim
|
||||
WORKDIR /app/frontend
|
||||
|
||||
COPY frontend/package-lock.json /tmp/package-lock.json
|
||||
|
||||
@@ -23,7 +23,7 @@ WORKDIR /app/backend/
|
||||
COPY [ "./backend/filebrowser", "./"]
|
||||
COPY [ "./backend/reduce-rounded-corners.css", "./no-rounded.css" ]
|
||||
RUN mkdir -p ./internal/web/dist
|
||||
COPY [ "./backend/internal/web/embed/", "./internal/web/dist/"]
|
||||
COPY [ "./frontend/dist/", "./internal/web/dist/"]
|
||||
|
||||
ENV FILEBROWSER_PLAYWRIGHT_TEST=true
|
||||
ENV CI=true
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
FROM gtstef/ffmpeg:9.0.2 AS ffmpeg
|
||||
|
||||
FROM ghcr.io/gtsteffaniak/playwright-base:chromium
|
||||
WORKDIR /app
|
||||
COPY --from=ffmpeg [ "/ffmpeg", "/ffprobe", "/usr/local/bin/" ]
|
||||
|
||||
# Copy setup scripts first to leverage caching
|
||||
COPY [ "./_docker/src/previews/", "./" ]
|
||||
@@ -10,8 +13,7 @@ COPY [ "./frontend/tests", "./tests" ]
|
||||
WORKDIR /app/backend/
|
||||
COPY [ "./backend/filebrowser", "./"]
|
||||
RUN mkdir -p ./internal/web/dist
|
||||
COPY [ "./backend/internal/web/embed/", "./internal/web/dist/"]
|
||||
COPY [ "./frontend/dist/", "./internal/web/dist/"]
|
||||
|
||||
# Run tests
|
||||
ENV FILEBROWSER_PLAYWRIGHT_TEST=true
|
||||
RUN ./filebrowser & sleep 2 && cd ../frontend && npx playwright test
|
||||
@@ -6,7 +6,7 @@ COPY [ "./frontend/tests", "./tests" ]
|
||||
WORKDIR /app/backend/
|
||||
COPY [ "./backend/filebrowser", "./"]
|
||||
RUN mkdir -p ./internal/web/dist
|
||||
COPY [ "./backend/internal/web/embed/", "./internal/web/dist/"]
|
||||
COPY [ "./frontend/dist/", "./internal/web/dist/"]
|
||||
RUN apt update && apt install nginx -y
|
||||
RUN mv default.conf /etc/nginx/conf.d/default.conf
|
||||
RUN mv .htpasswd /etc/nginx/conf.d/.htpasswd
|
||||
|
||||
@@ -10,7 +10,7 @@ COPY [ "./backend/filebrowser", "./"]
|
||||
COPY [ "./_docker/src/screenshots/backend/*", "./"]
|
||||
|
||||
RUN mkdir -p ./internal/web/dist
|
||||
COPY [ "./backend/internal/web/embed/", "./internal/web/dist/"]
|
||||
COPY [ "./frontend/dist/", "./internal/web/dist/"]
|
||||
|
||||
ENV FILEBROWSER_PLAYWRIGHT_TEST=true
|
||||
RUN ./filebrowser & sleep 2 && cd ../frontend && npx playwright test --project dark-screenshots
|
||||
@@ -13,7 +13,7 @@ WORKDIR /app/backend/
|
||||
COPY [ "./backend/filebrowser", "./"]
|
||||
COPY [ "./backend/reduce-rounded-corners.css", "./no-rounded.css"]
|
||||
RUN mkdir -p ./internal/web/dist
|
||||
COPY [ "./backend/internal/web/embed/", "./internal/web/dist/"]
|
||||
COPY [ "./frontend/dist/", "./internal/web/dist/"]
|
||||
|
||||
# Run tests
|
||||
ENV FILEBROWSER_PLAYWRIGHT_TEST=true
|
||||
|
||||
@@ -11,7 +11,7 @@ COPY [ "./frontend/tests/", "./tests" ]
|
||||
WORKDIR /app/backend/
|
||||
COPY [ "./backend/filebrowser", "./"]
|
||||
RUN mkdir -p ./internal/web/dist
|
||||
COPY [ "./backend/internal/web/embed/", "./internal/web/dist/"]
|
||||
COPY [ "./frontend/dist/", "./internal/web/dist/"]
|
||||
|
||||
# Run tests
|
||||
ENV FILEBROWSER_PLAYWRIGHT_TEST=true
|
||||
|
||||
@@ -9,7 +9,7 @@ RUN go build -tags analytics -ldflags="-w -s \
|
||||
-X 'github.com/gtsteffaniak/filebrowser/backend/internal/version.CommitSHA=${REVISION}'" \
|
||||
-o filebrowser .
|
||||
|
||||
FROM node:jod-slim AS nbuild
|
||||
FROM node:slim AS nbuild
|
||||
WORKDIR /build
|
||||
COPY ./frontend/package.json ./frontend/package-lock.json ./frontend/
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates \
|
||||
@@ -32,7 +32,7 @@ COPY --from=base --chown=filebrowser:1000 [ "/app/filebrowser", "./" ]
|
||||
COPY --from=base --chown=filebrowser:1000 [ "/app/config.yaml", "./data/config.yaml" ]
|
||||
COPY --from=base --chown=filebrowser:1000 [ "/app/config.yaml", "./" ]
|
||||
COPY --from=base --chown=filebrowser:1000 [ "/app/reduce-rounded-corners.css", "./" ]
|
||||
COPY --from=nbuild --chown=filebrowser:1000 [ "/build/backend/internal/web/dist/", "./internal/web/dist/" ]
|
||||
COPY --from=nbuild --chown=filebrowser:1000 [ "/build/frontend/dist/", "./internal/web/dist/" ]
|
||||
## sanity checks
|
||||
RUN [ "filebrowser", "version" ]
|
||||
# exposing default port for auto discovery.
|
||||
|
||||
@@ -20,3 +20,7 @@ userDefaults:
|
||||
account:
|
||||
permissions:
|
||||
share: true
|
||||
|
||||
integrations:
|
||||
media:
|
||||
skipHwCheck: true
|
||||
@@ -51,3 +51,7 @@ userDefaults:
|
||||
video: true
|
||||
office: true
|
||||
highQuality: true
|
||||
|
||||
integrations:
|
||||
media:
|
||||
skipHwCheck: true
|
||||
@@ -64,4 +64,7 @@ userDefaults:
|
||||
popup: true
|
||||
video: true
|
||||
office: true
|
||||
highQuality: true
|
||||
highQuality: true
|
||||
integrations:
|
||||
media:
|
||||
skipHwCheck: true
|
||||
@@ -50,4 +50,7 @@ userDefaults:
|
||||
permissions:
|
||||
admin: false
|
||||
share: false
|
||||
api: false
|
||||
api: false
|
||||
integrations:
|
||||
media:
|
||||
skipHwCheck: true
|
||||
@@ -18,3 +18,7 @@ userDefaults:
|
||||
account:
|
||||
permissions:
|
||||
share: true
|
||||
|
||||
integrations:
|
||||
media:
|
||||
skipHwCheck: true
|
||||
@@ -39,3 +39,10 @@ userDefaults:
|
||||
office: true
|
||||
models: true
|
||||
highQuality: true
|
||||
|
||||
integrations:
|
||||
media:
|
||||
skipHwCheck: true
|
||||
# Real HLS transcoding for the preview specs (requires ffmpeg in the image).
|
||||
transcode:
|
||||
enabled: true
|
||||
@@ -13,23 +13,20 @@ export default defineConfig({
|
||||
globalSetup: "./tests/playwright/previews-setup",
|
||||
timeout: 10000,
|
||||
testDir: "./tests/playwright/previews",
|
||||
/* Run tests in files in parallel */
|
||||
fullyParallel: true,
|
||||
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||
fullyParallel: false,
|
||||
forbidOnly: false,
|
||||
/* Retry on CI only */
|
||||
retries: 2,
|
||||
workers: 10,
|
||||
reporter: "line",
|
||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||
use: {
|
||||
launchOptions: {
|
||||
args: [
|
||||
'--disable-gpu',
|
||||
'--use-gl=swiftshader', // CPU-based WebGL renderer built into Chromium
|
||||
'--enable-webgl',
|
||||
'--disable-dev-shm-usage', // Overcome limited resource problems in Docker
|
||||
'--no-sandbox', // Required for Docker
|
||||
"--autoplay-policy=no-user-gesture-required",
|
||||
"--disable-gpu",
|
||||
"--use-gl=swiftshader",
|
||||
"--enable-webgl",
|
||||
"--disable-dev-shm-usage",
|
||||
"--no-sandbox",
|
||||
],
|
||||
},
|
||||
storageState: "previews.json",
|
||||
|
||||
@@ -40,3 +40,7 @@ userDefaults:
|
||||
account:
|
||||
permissions:
|
||||
share: true
|
||||
|
||||
integrations:
|
||||
media:
|
||||
skipHwCheck: true
|
||||
@@ -19,4 +19,7 @@ userDefaults:
|
||||
# Size 4: switch-view "gallery" family resolves to icons (not gallery); list family → list.
|
||||
gallerySize: 3
|
||||
account:
|
||||
showAdvancedProfile: true
|
||||
showAdvancedProfile: true
|
||||
integrations:
|
||||
media:
|
||||
skipHwCheck: true
|
||||
@@ -48,4 +48,7 @@ auth:
|
||||
|
||||
userDefaults:
|
||||
listing:
|
||||
showHidden: true
|
||||
showHidden: true
|
||||
integrations:
|
||||
media:
|
||||
skipHwCheck: true
|
||||
@@ -27,4 +27,7 @@ frontend:
|
||||
url: "https://playwright.dev/"
|
||||
title: "Playwright"
|
||||
styling:
|
||||
disableEventThemes: true
|
||||
disableEventThemes: true
|
||||
integrations:
|
||||
media:
|
||||
skipHwCheck: true
|
||||
+1
-1
@@ -7,7 +7,7 @@ env_files = [".air.env"]
|
||||
entrypoint = "./tmp/filebrowser"
|
||||
args_bin = ["-c", "test_config.yaml"]
|
||||
include_ext = ["go", "tpl", "tmpl", "html"]
|
||||
exclude_dir = ["tmp", "vendor", "internal/web/dist", "internal/web/embed", "internal/preview/testdata", "internal/preview/thumbnails", "internal/preview/heic", "swagger/docs", "internal/preview/gofitzinclude"]
|
||||
exclude_dir = ["tmp", "vendor", "internal/web/dist", "internal/preview/testdata", "internal/preview/thumbnails", "internal/preview/heic", "swagger/docs"]
|
||||
poll = true
|
||||
poll_interval = 1000
|
||||
log = "air.log"
|
||||
|
||||
@@ -17,7 +17,7 @@ linters:
|
||||
exhaustive:
|
||||
check:
|
||||
- switch
|
||||
- map
|
||||
- mapliteral
|
||||
exhaustruct:
|
||||
exclude:
|
||||
- ^net/http.Client$
|
||||
|
||||
+39
-115
@@ -5,137 +5,61 @@ version: 2
|
||||
before:
|
||||
hooks:
|
||||
- go mod download
|
||||
- go run ./scripts/setup-gofitz-cgo
|
||||
|
||||
builds:
|
||||
# Build configuration for linux amd64
|
||||
- id: linux-amd64
|
||||
- id: filebrowser
|
||||
main: main.go
|
||||
# Flat dist layout without GOAMD64/GOARM64/GORISCV64 suffix folders (e.g. _v1, _v8.0).
|
||||
no_unique_dist_dir: true
|
||||
binary: >-
|
||||
{{ .Os }}-{{ .Arch }}{{ if eq .Arch "arm" }}-{{ .Arm }}{{ end }}/filebrowser
|
||||
env:
|
||||
- CGO_ENABLED=1
|
||||
- CC=zig cc -target x86_64-linux-musl
|
||||
- CGO_ENABLED=0
|
||||
flags:
|
||||
- -trimpath
|
||||
tags:
|
||||
- analytics
|
||||
- mupdf
|
||||
- musl
|
||||
ldflags: &ldflags
|
||||
ldflags:
|
||||
- -s -w -X github.com/gtsteffaniak/filebrowser/backend/internal/version.Version=v{{ .Version }} -X github.com/gtsteffaniak/filebrowser/backend/internal/version.CommitSHA={{ .ShortCommit }}
|
||||
main: main.go
|
||||
binary: filebrowser
|
||||
goos:
|
||||
- linux
|
||||
goarch:
|
||||
- amd64
|
||||
hooks:
|
||||
post:
|
||||
- upx {{ .Path }}
|
||||
|
||||
# Build configuration for linux arm64
|
||||
- id: linux-arm64
|
||||
ldflags: *ldflags
|
||||
main: main.go
|
||||
binary: filebrowser
|
||||
env:
|
||||
- CGO_ENABLED=1
|
||||
- CC=zig cc -target aarch64-linux-musl
|
||||
tags:
|
||||
- analytics
|
||||
- mupdf
|
||||
- musl
|
||||
goos:
|
||||
- linux
|
||||
goarch:
|
||||
- arm64
|
||||
hooks:
|
||||
post:
|
||||
- upx {{ .Path }}
|
||||
|
||||
# Build configuration for linux riscv64
|
||||
- id: linux-riscv64
|
||||
ldflags: *ldflags
|
||||
main: main.go
|
||||
binary: filebrowser
|
||||
env:
|
||||
- CC=zig cc -target riscv64-linux-musl
|
||||
# go-fitz does not provide riscv64 MuPDF libraries yet: https://github.com/gen2brain/go-fitz/tree/master/libs
|
||||
tags:
|
||||
- analytics
|
||||
- musl
|
||||
goos:
|
||||
- linux
|
||||
goarch:
|
||||
- riscv64
|
||||
|
||||
# Build configuration for linux
|
||||
- id: linux-arm32
|
||||
ldflags: *ldflags
|
||||
main: main.go
|
||||
binary: filebrowser
|
||||
tags:
|
||||
- analytics
|
||||
goos:
|
||||
- linux
|
||||
goarch:
|
||||
- arm
|
||||
goarm:
|
||||
- "6"
|
||||
- "7"
|
||||
hooks:
|
||||
post:
|
||||
- upx {{ .Path }} # Compress the binary with UPX
|
||||
|
||||
# Build configuration for windows without arm
|
||||
- id: windows
|
||||
env:
|
||||
- CGO_ENABLED=1
|
||||
# windows-gnu avoids zig rejecting Go's -tsaware when cross-compiling from macOS
|
||||
- CC=zig cc -target x86_64-windows-gnu -lc
|
||||
tags:
|
||||
- analytics
|
||||
- mupdf
|
||||
ldflags: *ldflags
|
||||
main: main.go
|
||||
binary: filebrowser
|
||||
goos:
|
||||
- windows
|
||||
goarch:
|
||||
- amd64
|
||||
hooks:
|
||||
post:
|
||||
- upx {{ .Path }} # Compress the binary with UPX
|
||||
|
||||
# Build configuration for freebsd without arm & upx
|
||||
- id: freeBSD and freebsd-arm
|
||||
ldflags: *ldflags
|
||||
main: main.go
|
||||
binary: filebrowser
|
||||
tags:
|
||||
- analytics
|
||||
goos:
|
||||
- darwin
|
||||
- freebsd
|
||||
goarch:
|
||||
- amd64
|
||||
|
||||
# Build configuration for macos without upx (no mupdf: CGO cross-compile from Linux CI is unsupported)
|
||||
- id: macos
|
||||
ldflags: *ldflags
|
||||
main: main.go
|
||||
binary: filebrowser
|
||||
tags:
|
||||
- analytics
|
||||
goos:
|
||||
- darwin
|
||||
goarch:
|
||||
- arm64
|
||||
- amd64
|
||||
- arm
|
||||
- riscv64
|
||||
goarm:
|
||||
- "6"
|
||||
- "7"
|
||||
ignore:
|
||||
- goos: windows
|
||||
goarch: arm
|
||||
- goos: windows
|
||||
goarch: riscv64
|
||||
- goos: darwin
|
||||
goarch: arm
|
||||
- goos: darwin
|
||||
goarch: riscv64
|
||||
- goos: freebsd
|
||||
goarch: arm
|
||||
- goos: freebsd
|
||||
goarch: arm64
|
||||
- goos: freebsd
|
||||
goarch: riscv64
|
||||
|
||||
archives:
|
||||
- name_template: >
|
||||
{{- if eq .Os "windows" -}}
|
||||
{{.ProjectName}}
|
||||
{{.ProjectName}}{{ if ne .Arch "amd64" }}-{{ .Arch }}{{ end }}
|
||||
{{- else if eq .Arch "arm" -}}
|
||||
{{.Os}}-arm-{{ .Arm }}-{{.ProjectName}}
|
||||
{{- else -}}
|
||||
{{.Os}}-{{.Arch}}{{if .Arm}}v{{.Arm}}{{end}}-{{.ProjectName}}
|
||||
{{.Os}}-{{.Arch}}-{{.ProjectName}}
|
||||
{{- end -}}
|
||||
formats: [ 'binary' ]
|
||||
|
||||
checksum:
|
||||
disable: true
|
||||
formats: ["tar.gz"]
|
||||
format_overrides:
|
||||
- goos: windows
|
||||
formats: ["zip"]
|
||||
+1
-53
@@ -56,8 +56,6 @@ github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8v
|
||||
github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
|
||||
github.com/alecthomas/chroma/v2 v2.27.0 h1:FodwmyOBgJULFYmDqibcp9pvfDLWdtPRh9v/r5BXYZs=
|
||||
github.com/alecthomas/chroma/v2 v2.27.0/go.mod h1:NjJ3ciIgrqBNeIkWZ4e46nseoLDslxU1LmfCoL+wcY8=
|
||||
github.com/alecthomas/go-check-sumtype v0.4.0 h1:gd4mE4QsA62sXlnFIs8GUv8/0xH3DOUqTkYQR1l2v28=
|
||||
github.com/alecthomas/go-check-sumtype v0.4.0/go.mod h1:aYYllI8IXNjo7ZYUzI2+wyLRECMg3zo+8CZj9JTBAWU=
|
||||
github.com/alecthomas/go-check-sumtype v0.5.1-0.20260828200218-ae6904d28606 h1:dXPJ+uOJLWb8rjlAuLX7JPiRJtZKw/53Ol+WxdDJ1Eo=
|
||||
github.com/alecthomas/go-check-sumtype v0.5.1-0.20260828200218-ae6904d28606/go.mod h1:ZH31IJyNpxpStxP2ayCcPQz+3T2G/OnxIQqe4LWvSDw=
|
||||
github.com/alecthomas/repr v0.5.2 h1:SU73FTI9D1P5UNtvseffFSGmdNci/O6RsqzeXJtP0Qs=
|
||||
@@ -122,8 +120,6 @@ github.com/bombsimon/wsl/v4 v4.7.0 h1:1Ilm9JBPRczjyUs6hvOPKvd7VL1Q++PL8M0SXBDf+j
|
||||
github.com/bombsimon/wsl/v4 v4.7.0/go.mod h1:uV/+6BkffuzSAVYD+yGyld1AChO7/EuLrCF/8xTiapg=
|
||||
github.com/bombsimon/wsl/v5 v5.9.0 h1:WCrgZ7RQnZO5oEwbVTlYgBdU3wL294kR1BSWV8vTfsU=
|
||||
github.com/bombsimon/wsl/v5 v5.9.0/go.mod h1:kjo4HiAV5FDkHC8/uzJq9mBffEEd6WT/nvN7DoMovDM=
|
||||
github.com/breml/bidichk v0.3.3 h1:WSM67ztRusf1sMoqH6/c4OBCUlRVTKq+CbSeo0R17sE=
|
||||
github.com/breml/bidichk v0.3.3/go.mod h1:ISbsut8OnjB367j5NseXEGGgO/th206dVa427kR8YTE=
|
||||
github.com/breml/bidichk v0.3.4 h1:70G6w80G6GDZTUURHTC5gBKVjMLMw2736CzXquSf5Ek=
|
||||
github.com/breml/bidichk v0.3.4/go.mod h1:GOHprnh4i0V7HrvWjtbvbpicTUcqoYt9zYESKcJkk4M=
|
||||
github.com/breml/errchkjson v0.4.1 h1:keFSS8D7A2T0haP9kzZTi7o26r7kE3vymjZNeNDRDwg=
|
||||
@@ -142,8 +138,6 @@ github.com/charithe/durationcheck v0.0.11 h1:g1/EX1eIiKS57NTWsYtHDZ/APfeXKhye1Di
|
||||
github.com/charithe/durationcheck v0.0.11/go.mod h1:x5iZaixRNl8ctbM+3B2RrPG5t856TxRyVQEnbIEM2X4=
|
||||
github.com/charmbracelet/colorprofile v0.4.3 h1:QPa1IWkYI+AOB+fE+mg/5/4HRMZcaXex9t5KX76i20Q=
|
||||
github.com/charmbracelet/colorprofile v0.4.3/go.mod h1:/zT4BhpD5aGFpqQQqw7a+VtHCzu+zrQtt1zhMt9mR4Q=
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20260910203606-6c9e17dc7a16 h1:/hSCZO1puetbGd2JikHKN0nAcb2mFevzxJElFoduhaw=
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20260910203606-6c9e17dc7a16/go.mod h1:JFvmQPZh3uAu7PpSZU91bcR0BrIy24HhW+0EsW1uGxE=
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20260922123528-4e49372c11f9 h1:ZGHc3eaN2TIhkpwRibtr8N9jLQJOY1rh6GEByRoRmp4=
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20260922123528-4e49372c11f9/go.mod h1:D9SVXVpAsD1pP6xR6BiERbe4+dUU6EW9US1TFrNutGA=
|
||||
github.com/charmbracelet/x/ansi v0.11.8 h1:JMFwp0CgDC2+jcOB162HH5k7I3FVbgFSMMYg7dSPBQQ=
|
||||
@@ -288,8 +282,6 @@ github.com/gohugoio/hugo-goldmark-extensions/passthrough v0.5.0 h1:p13Q0DBCrBRpJ
|
||||
github.com/gohugoio/hugo-goldmark-extensions/passthrough v0.5.0/go.mod h1:ob9PCHy/ocsQhTz68uxhyInaYCbbVNpOOrJkIoSeD+8=
|
||||
github.com/golangci/asciicheck v0.5.0 h1:jczN/BorERZwK8oiFBOGvlGPknhvq0bjnysTj4nUfo0=
|
||||
github.com/golangci/asciicheck v0.5.0/go.mod h1:5RMNAInbNFw2krqN6ibBxN/zfRFa9S6tA1nPdM0l8qQ=
|
||||
github.com/golangci/canonicalheader v0.0.0-20260827115959-a25c71c521f6 h1:fVLolA3dG6s0brGetsiDAtcnpMSwVa2LqXJEw/9RJG4=
|
||||
github.com/golangci/canonicalheader v0.0.0-20260827115959-a25c71c521f6/go.mod h1:1xo+NFW5S+bEf2DKXhaxuzvcDN5AR6o/KMwvqC5Mkpo=
|
||||
github.com/golangci/canonicalheader v0.0.0-20260928145534-e18e5c5a078f h1:pOnwRNeWLPkADfkgqKcCP7RPQAS9OIzffaBaktRsKnk=
|
||||
github.com/golangci/canonicalheader v0.0.0-20260928145534-e18e5c5a078f/go.mod h1:aXo+AVSX0pC3TRo2wAfR92YwBKfG6C2eal+omjKXwYw=
|
||||
github.com/golangci/dupl v0.0.0-20260401084720-c99c5cf5c202 h1:CbTB8KpqnViI6lIXxp03Oclc4VFHi3K4BWC1TacsZ+A=
|
||||
@@ -298,14 +290,8 @@ github.com/golangci/go-printf-func-name v0.1.1 h1:hIYTFJqAGp1iwoIfsNTpoq1xZAarog
|
||||
github.com/golangci/go-printf-func-name v0.1.1/go.mod h1:Es64MpWEZbh0UBtTAICOZiB+miW53w/K9Or/4QogJss=
|
||||
github.com/golangci/gofmt v0.0.0-20260820135601-e84e05053792 h1:WL8YKrt3UbOBqSRU7GpP5BTtQTMWtVtj+mfPijgZeIg=
|
||||
github.com/golangci/gofmt v0.0.0-20260820135601-e84e05053792/go.mod h1:te5hX0dW4C5r6YbXs+6ysNr8Q5UTmdIqGbb+mlFiYmA=
|
||||
github.com/golangci/golangci-lint/v2 v2.13.2 h1:bCyq3E4vo9qwzifjpzJqYndEt7Ncva80qkk8G2B4TXU=
|
||||
github.com/golangci/golangci-lint/v2 v2.13.2/go.mod h1:5xaMd1kAxV7GSBPEyngw8gnnjoRocqW9UVKdBR6627w=
|
||||
github.com/golangci/golangci-lint/v2 v2.14.0 h1:ot8QffRa4LzAAEgtvNYrVs9esxQ7xoTwoAv6uhp4ngA=
|
||||
github.com/golangci/golangci-lint/v2 v2.14.0/go.mod h1:amHimCzNDP1GfVno3hIiNssjvqXmuW+CPZAHOdR4cIc=
|
||||
github.com/golangci/golangci-lint/v2 v2.15.0 h1:w94zf8HAYI7hm3164kwKsvZRuqXvY+YxeFoTbu1OLg8=
|
||||
github.com/golangci/golangci-lint/v2 v2.15.0/go.mod h1:/FRI304IxqDVhX2o3ZZ0qp8Vvz8egJdzCY5A4GjvmTU=
|
||||
github.com/golangci/golines v0.15.0 h1:Qnph25g8Y1c5fdo1X7GaRDGgnMHgnxh4Gk4VfPTtRx0=
|
||||
github.com/golangci/golines v0.15.0/go.mod h1:AZjXd23tbHMpowhtnGlj9KCNsysj72aeZVVHnVcZx10=
|
||||
github.com/golangci/golines v0.16.0 h1:xKdwzRvwzLd7V131B/dv90vUiEoTA0vQybdeqperPOg=
|
||||
github.com/golangci/golines v0.16.0/go.mod h1:mCMgRQHiCvuALJOeaNtylu09zbzvS9Ka01dfvLLJios=
|
||||
github.com/golangci/misspell v0.8.0 h1:qvxQhiE2/5z+BVRo1kwYA8yGz+lOlu5Jfvtx2b04Jbg=
|
||||
@@ -314,8 +300,6 @@ github.com/golangci/plugin-module-register v0.1.2 h1:e5WM6PO6NIAEcij3B053CohVp3H
|
||||
github.com/golangci/plugin-module-register v0.1.2/go.mod h1:1+QGTsKBvAIvPvoY/os+G5eoqxWn70HYDm2uvUyGuVw=
|
||||
github.com/golangci/revgrep v0.8.0 h1:EZBctwbVd0aMeRnNUsFogoyayvKHyxlV3CdUA46FX2s=
|
||||
github.com/golangci/revgrep v0.8.0/go.mod h1:U4R/s9dlXZsg8uJmaR1GrloUr14D7qDl8gi2iPXJH8k=
|
||||
github.com/golangci/rowserrcheck v0.0.0-20260901154044-241134db7241 h1:0kPqfqytQizeQ9WBk487NcsGcRdS8YhHeUhXxkfEAhA=
|
||||
github.com/golangci/rowserrcheck v0.0.0-20260901154044-241134db7241/go.mod h1:lczq5oJ8PxpMESQG6dO3iFYTQPhpqoMOYw//n2FEnHA=
|
||||
github.com/golangci/rowserrcheck v0.0.0-20261005233414-e0740d52dee8 h1:oN042y1yEcpldrqY81puyNA4ZjQZJzt0U/t7HyYrMic=
|
||||
github.com/golangci/rowserrcheck v0.0.0-20261005233414-e0740d52dee8/go.mod h1:T1Bg58Sk3N352aBbPLJPpHykFWxEEwV3o4/Enn+PPU8=
|
||||
github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e h1:ai0EfmVYE2bRA5htgAG9r7s3tHsfjIhN98WshBTJ9jM=
|
||||
@@ -373,8 +357,6 @@ github.com/julz/importas v0.2.0 h1:y+MJN/UdL63QbFJHws9BVC5RpA2iq0kpjrFajTGivjQ=
|
||||
github.com/julz/importas v0.2.0/go.mod h1:pThlt589EnCYtMnmhmRYY/qn9lCf/frPOK+WMx3xiJY=
|
||||
github.com/karamaru-alpha/copyloopvar v1.2.2 h1:yfNQvP9YaGQR7VaWLYcfZUlRP2eo2vhExWKxD/fP6q0=
|
||||
github.com/karamaru-alpha/copyloopvar v1.2.2/go.mod h1:oY4rGZqZ879JkJMtX3RRkcXRkmUvH0x35ykgaKgsgJY=
|
||||
github.com/kisielk/errcheck v1.20.0 h1:9rwHBNKzd4wkDWcROy3DvFGNqEPlkxBg305rvk7HabI=
|
||||
github.com/kisielk/errcheck v1.20.0/go.mod h1:O+f80MKNwX8Oor2jwgpeQ9An7uJm+hRSgT+h22knRJU=
|
||||
github.com/kisielk/errcheck v1.30.0 h1:ZIxNDAfAd4larXHTceoZP/dYPAB90dHg1OYhA2sVh5k=
|
||||
github.com/kisielk/errcheck v1.30.0/go.mod h1:uiCAInmFuyOje4VDdbQSP9mgqf5gORYSXrDf19XilsI=
|
||||
github.com/kkHAIKE/contextcheck v1.1.6 h1:7HIyRcnyzxL9Lz06NGhiKvenXq7Zw6Q0UQu/ttjfJCE=
|
||||
@@ -388,8 +370,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/kulti/thelper v0.7.1 h1:fI8QITAoFVLx+y+vSyuLBP+rcVIB8jKooNSCT2EiI98=
|
||||
github.com/kulti/thelper v0.7.1/go.mod h1:NsMjfQEy6sd+9Kfw8kCP61W1I0nerGSYSFnGaxQkcbs=
|
||||
github.com/kunwardeep/paralleltest v1.0.15 h1:ZMk4Qt306tHIgKISHWFJAO1IDQJLc6uDyJMLyncOb6w=
|
||||
github.com/kunwardeep/paralleltest v1.0.15/go.mod h1:di4moFqtfz3ToSKxhNjhOZL+696QtJGCFe132CbBLGk=
|
||||
github.com/kunwardeep/paralleltest v1.0.16 h1:I0gQkLNgfigjpxWAGhx7PYj3VpswzfGrSV/715t6g+o=
|
||||
github.com/kunwardeep/paralleltest v1.0.16/go.mod h1:di4moFqtfz3ToSKxhNjhOZL+696QtJGCFe132CbBLGk=
|
||||
github.com/kyokomi/emoji/v2 v2.2.14 h1:YOF6VL52613M0Qr9v4puJDD9QQPmyyjXedDDlrGzH80=
|
||||
@@ -428,18 +408,12 @@ github.com/matoous/godox v1.1.0 h1:W5mqwbyWrwZv6OQ5Z1a/DHGMOvXYCBP3+Ht7KMoJhq4=
|
||||
github.com/matoous/godox v1.1.0/go.mod h1:jgE/3fUXiTurkdHOLT5WEkThTSuE7yxHv5iWPa80afs=
|
||||
github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE=
|
||||
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
|
||||
github.com/mattn/go-colorable v0.1.15 h1:+u9SLTRGnXv73cEsnsmoZBom+dMU88B2M0aDcWy0/jY=
|
||||
github.com/mattn/go-colorable v0.1.15/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-colorable v0.1.16 h1:+2YjeAe7xP1OQbZW1jERPWWCDLlNqFNCvjiqGiAt84A=
|
||||
github.com/mattn/go-colorable v0.1.16/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI=
|
||||
github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A=
|
||||
github.com/mattn/go-runewidth v0.0.30 h1:+KUuiDA4fF0R1p5FeueHefjDm+GIM+kWfFnDjybOPgk=
|
||||
github.com/mattn/go-runewidth v0.0.30/go.mod h1:3qAiGCV4Koz/yuveO58qUefmUTRm8r0IGEXZ9jeHp/8=
|
||||
github.com/mgechev/revive v1.16.0 h1:9OZVO8xOPUwIYynplHXv7liMllPQ/BTNZLp07sM/Im0=
|
||||
github.com/mgechev/revive v1.16.0/go.mod h1:nT854jMmvQsS/qqxEaMPM4pJSUpxhcPoHM788ZxDvdQ=
|
||||
github.com/mgechev/revive v1.17.0 h1:hwTTVC3svSv9X2FA2hiYT17Uws+lfxDWhPxzBZZCREg=
|
||||
github.com/mgechev/revive v1.17.0/go.mod h1:uiVNUF8ruVh4WHm/aPs7kKEeuo+m6oO3tuOfniyzP/g=
|
||||
github.com/mgechev/revive v1.17.1 h1:z8hV0L3uJ6yrwOMnJbkc5qBJpxXa2AxYKFKERGJyA4s=
|
||||
github.com/mgechev/revive v1.17.1/go.mod h1:FRd64pJwWSEE6j8ESoaX0PixPzjh2rpNSfckbEu3rIE=
|
||||
github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
|
||||
@@ -460,13 +434,8 @@ github.com/nakabonne/nestif v0.3.1 h1:wm28nZjhQY5HyYPx+weN3Q65k6ilSBxDb8v5S81B81
|
||||
github.com/nakabonne/nestif v0.3.1/go.mod h1:9EtoZochLn5iUprVDmDjqGKPofoUEBL8U4Ngq6aY7OE=
|
||||
github.com/niklasfasching/go-org v1.9.1 h1:/3s4uTPOF06pImGa2Yvlp24yKXZoTYM+nsIlMzfpg/0=
|
||||
github.com/niklasfasching/go-org v1.9.1/go.mod h1:ZAGFFkWvUQcpazmi/8nHqwvARpr1xpb+Es67oUGX/48=
|
||||
github.com/nishanths/exhaustive v0.13.0 h1:Rof0axOSNQaaPaPmLK5RxcRrJV2Vcv+vfUmuRy+2EAM=
|
||||
github.com/nishanths/exhaustive v0.13.0/go.mod h1:3/adQjJgvD/UFHHSYBjpK9Wbz8DOvf0FBtzx+zI0Rlo=
|
||||
github.com/nishanths/exhaustive v0.15.0 h1:uFjiO/WvrwQG+ojSZ+vtl/jAFbqA2oAtfpUWK/iKQ8M=
|
||||
github.com/nishanths/exhaustive v0.15.0/go.mod h1:2by9rYmg9FnsnLQC4Ixig4fQaWxRsY7RluxJuAu9sa0=
|
||||
github.com/nishanths/exhaustive v0.16.0/go.mod h1:/nBwAMRn2QmCjWQ3PiJ939yRSwvWLKSa21L2C6Tp84E=
|
||||
github.com/nishanths/predeclared v0.2.2 h1:V2EPdZPliZymNAn79T8RkNApBjMmVKh5XRpLm/w98Vk=
|
||||
github.com/nishanths/predeclared v0.2.2/go.mod h1:RROzoN6TnGQupbC+lqggsOlcgysk3LMK/HI84Mp280c=
|
||||
github.com/nishanths/predeclared v0.3.0 h1:W3i3JK/DZS5h7QwsEIyU8ler4Z2vwEwQSxNrZzhnlfk=
|
||||
github.com/nishanths/predeclared v0.3.0/go.mod h1:gN4uryPExDME/zmZdqkKIPSAqcfprj316ZDI6UTqz70=
|
||||
github.com/nunnatsa/ginkgolinter v0.24.0 h1:Mp0EagluLFP98JatP6nqp/gGEoljNG97uf9AcxcBVy8=
|
||||
@@ -598,16 +567,10 @@ github.com/tetafro/godot v1.5.6 h1:IEkrFCwXaYHlOn4mGzGS3F3dkP6m9t0jpwqBFPIkKiA=
|
||||
github.com/tetafro/godot v1.5.6/go.mod h1:eOkMrVQurDui411nBY2FA05EYH01r14LuWY/NrVDVcU=
|
||||
github.com/tetratelabs/wazero v1.12.0 h1:DuWcpNu/FzgEXgGBDp8J1Spc+CWOvvtvVyjKlaZopYU=
|
||||
github.com/tetratelabs/wazero v1.12.0/go.mod h1:LvKtzl2RqO4gyF27BiXU+nKAjcV8f38U+kP/q2vgxh0=
|
||||
github.com/timakin/bodyclose v0.0.0-20260723120731-857993a2939c h1:d/FUP8GD4QiY/rdFzZmBu3KqL9eBNVzMu7W/5pGkaMM=
|
||||
github.com/timakin/bodyclose v0.0.0-20260723120731-857993a2939c/go.mod h1:sDHLK7rb/59v/ZxZ7KtymgcoxuUMxjXq8gtu9VMOK8M=
|
||||
github.com/timakin/bodyclose v0.0.0-20260923065923-98ded9ab4ef2 h1:HECVafB2AKntWWRfsiQ4gdunLx5WOYQzFdCsxqOrzp8=
|
||||
github.com/timakin/bodyclose v0.0.0-20260923065923-98ded9ab4ef2/go.mod h1:JLoPVtROtNgJ99yXTIxuGNttvmJa85tkJAO6lr05qBA=
|
||||
github.com/timonwong/loggercheck v0.12.0 h1:7Cb9XGLJZSWYNjgL459DIhpSiEHupD+MLQ6vaN2Pl3g=
|
||||
github.com/timonwong/loggercheck v0.12.0/go.mod h1:Wa6Y+SJHQR01mViZlLLY5GAZVOWOLNMbkXddMjFWQCs=
|
||||
github.com/timonwong/loggercheck v0.13.0 h1:6amIOmLLPFYt24rXUbNWzcJeNGuJc+3c31tZtO85VHs=
|
||||
github.com/timonwong/loggercheck v0.13.0/go.mod h1:thn3allpox0fI5JeUWTCwiwp45peQxCZZHkHuA1Oc6I=
|
||||
github.com/tomarrell/wrapcheck/v2 v2.12.0 h1:H/qQ1aNWz/eeIhxKAFvkfIA+N7YDvq6TWVFL27Of9is=
|
||||
github.com/tomarrell/wrapcheck/v2 v2.12.0/go.mod h1:AQhQuZd0p7b6rfW+vUwHm5OMCGgp63moQ9Qr/0BpIWo=
|
||||
github.com/tomarrell/wrapcheck/v2 v2.13.0 h1:jYbLNs8PDkzGCY6d5LUzJdY7Bq//CTlb2HxZGV5z0JY=
|
||||
github.com/tomarrell/wrapcheck/v2 v2.13.0/go.mod h1:AQhQuZd0p7b6rfW+vUwHm5OMCGgp63moQ9Qr/0BpIWo=
|
||||
github.com/tommy-muehle/go-mnd/v2 v2.5.1 h1:NowYhSdyE/1zwK9QCLeRb6USWdoif80Ie+v+yU8u1Zw=
|
||||
@@ -618,12 +581,8 @@ github.com/ultraware/whitespace v0.2.0 h1:TYowo2m9Nfj1baEQBjuHzvMRbp19i+RCcRYrSW
|
||||
github.com/ultraware/whitespace v0.2.0/go.mod h1:XcP1RLD81eV4BW8UhQlpaR+SDc2givTvyI8a586WjW8=
|
||||
github.com/urfave/cli/v2 v2.27.7 h1:bH59vdhbjLv3LAvIu6gd0usJHgoTTPhCFib8qqOwXYU=
|
||||
github.com/urfave/cli/v2 v2.27.7/go.mod h1:CyNAG/xg+iAOg0N4MPGZqVmv2rCoP267496AOXUZjA4=
|
||||
github.com/uudashr/gocognit v1.2.1 h1:CSJynt5txTnORn/DkhiB4mZjwPuifyASC8/6Q0I/QS4=
|
||||
github.com/uudashr/gocognit v1.2.1/go.mod h1:acaubQc6xYlXFEMb9nWX2dYBzJ/bIjEkc1zzvyIZg5Q=
|
||||
github.com/uudashr/gocognit v1.3.0 h1:Xdw5JwAoYmX3WAB+wsXY3nxEwdw7+MWAnM0wCAAv7A4=
|
||||
github.com/uudashr/gocognit v1.3.0/go.mod h1:acaubQc6xYlXFEMb9nWX2dYBzJ/bIjEkc1zzvyIZg5Q=
|
||||
github.com/uudashr/iface v1.5.1 h1:BS3yrgaT55s3dAtJoxuTnsZNbsejq/mVuzp49YDyfBA=
|
||||
github.com/uudashr/iface v1.5.1/go.mod h1:5UWoT6SvTdTww/KToRj6clO+n4Kg3/NrAQvgOB+5Ggw=
|
||||
github.com/uudashr/iface v1.5.3 h1:N61bzr11L7BHP6Rct+C6zQePHjSTMeyVBq+s03uB/Ds=
|
||||
github.com/uudashr/iface v1.5.3/go.mod h1:5UWoT6SvTdTww/KToRj6clO+n4Kg3/NrAQvgOB+5Ggw=
|
||||
github.com/xen0n/gosmopolitan v1.3.0 h1:zAZI1zefvo7gcpbCOrPSHJZJYA9ZgLfJqtKzZ5pHqQM=
|
||||
@@ -690,8 +649,6 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.41.0 h1:qJmnOUb4YB+FsEuM3HcWucdZASCPGhsX6uljO6pog0c=
|
||||
golang.org/x/mod v0.41.0/go.mod h1:Ek9pY8RKWXwsWvd3rQiHYtMqkjSUV+s1Rj7j4H5Ur6o=
|
||||
golang.org/x/mod v0.42.0 h1:ICeL3t2L30ljSPHHxDnR4fqVcBt/zR2zJAb9juavmQg=
|
||||
golang.org/x/mod v0.42.0/go.mod h1:u5fzIrRInkL8MaO1cbRkUHT64v303YIT5KEqpNr7jRs=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
@@ -703,9 +660,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
|
||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.59.0 h1:5zfYln+w5XCxwrnMMJPufRgNoXEaGxl0wo5GqPXyues=
|
||||
golang.org/x/net v0.59.0/go.mod h1:2DA/G1UfVbCpQPeWTmMPGY7Cs2PkBkwu743bVX5PIVg=
|
||||
golang.org/x/net v0.61.0 h1:RR+6j/BTBCrggOLugxa+66R8FvoN6MHlzDlZIbN9YFw=
|
||||
golang.org/x/net v0.61.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@@ -713,8 +669,6 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.23.0 h1:KameEIfc1IkluZyXWLn39Wd4tURc6GbCiISGiZm2bQk=
|
||||
golang.org/x/sync v0.23.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
||||
golang.org/x/sync v0.24.0 h1:iqiDrGoDgyuvAKrhLQthUEzU/R378N78gXbBjxed7oA=
|
||||
golang.org/x/sync v0.24.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -730,8 +684,6 @@ golang.org/x/sys v0.0.0-20211105183446-c75c47738b0c/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
|
||||
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA=
|
||||
golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
@@ -754,8 +706,6 @@ golang.org/x/tools v0.1.1-0.20210302220138-2ac05c832e1a/go.mod h1:9bzcO0MWcOuT0t
|
||||
golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.50.0 h1:c2ifzfcuY7L90lZ2aKd8S4K2NpASF08SZx9ZuJkHmSU=
|
||||
golang.org/x/tools v0.50.0/go.mod h1:7ulVMw3831Mwi5EZD6RomGyffr4VFjuNYXf2BbCEAV0=
|
||||
golang.org/x/tools v0.52.0 h1:ryxg4U63oaUYk7uOLTF37n43f4qgtGvqV4Ioit1BaEs=
|
||||
golang.org/x/tools v0.52.0/go.mod h1:ItcP5UNaVGG+Yc4eIYmaFLNJ4soEopkx5Y2d4lcEurs=
|
||||
golang.org/x/tools/go/expect v0.1.1-deprecated h1:jpBZDwmgPhXsKZC6WhL20P4b/wmnpsEAGHaNy0n/rJM=
|
||||
@@ -774,8 +724,6 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.8.1 h1:+JKf3xJ1ni4CwrhVg4/pqsfPGP6vNAXcKbMXJodYx3w=
|
||||
honnef.co/go/tools v0.8.1/go.mod h1:XA+OnlRA9EDh/ukGvXMNSZNKGwFQJ+5dER0ioUkOxks=
|
||||
honnef.co/go/tools v0.8.2 h1:+jPbCzuYxYrcoOvCecYUFDj+XJQRmzIhJmlbpps21Zk=
|
||||
honnef.co/go/tools v0.8.2/go.mod h1:xG1Q4n+mg3bKZrO6RWFA9jFlkqplflmDRHGeuexiLDs=
|
||||
mvdan.cc/gofumpt v0.12.0 h1:1Lbudkz2kpM9Cjz2pL4M19u7q+GaEhCTNf7N9mfpcho=
|
||||
|
||||
+16
-11
@@ -293,18 +293,23 @@ func createConfig(configpath string, noInput bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// setupConfigYAMLCandidates lists on-disk setup templates for config.generated.yaml.
|
||||
var setupConfigYAMLCandidates = []string{
|
||||
"frontend/public/config.generated.yaml",
|
||||
"../frontend/public/config.generated.yaml",
|
||||
"internal/web/dist/config.generated.yaml",
|
||||
"../internal/web/dist/config.generated.yaml",
|
||||
"backend/internal/web/dist/config.generated.yaml",
|
||||
}
|
||||
|
||||
func readSetupConfigTemplateYAML() (string, error) {
|
||||
return settings.ReadFirstExistingFile(setupConfigYAMLCandidates)
|
||||
}
|
||||
|
||||
func generateSetupConfigYAML(config *settings.Settings) (string, error) {
|
||||
embeddedPaths := []string{
|
||||
"frontend/public/config.generated.yaml",
|
||||
"../frontend/public/config.generated.yaml",
|
||||
"internal/web/dist/config.generated.yaml",
|
||||
"../internal/web/dist/config.generated.yaml",
|
||||
}
|
||||
for _, path := range embeddedPaths {
|
||||
embeddedYaml, err := os.ReadFile(path)
|
||||
if err == nil && len(embeddedYaml) > 0 {
|
||||
return settings.GenerateConfigYamlWithEmbedded(config, true, false, false, string(embeddedYaml))
|
||||
}
|
||||
embeddedYaml, err := readSetupConfigTemplateYAML()
|
||||
if err == nil {
|
||||
return settings.GenerateConfigYamlWithEmbedded(config, true, false, false, embeddedYaml)
|
||||
}
|
||||
return settings.GenerateConfigYaml(config, true, false, false)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func writeSetupConfigYAML(t *testing.T, root, relPath, content string) {
|
||||
t.Helper()
|
||||
path := filepath.Join(root, filepath.FromSlash(relPath))
|
||||
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(path, []byte(content), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadSetupConfigTemplateYAML_fromDist(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
writeSetupConfigYAML(t, root, "internal/web/dist/config.generated.yaml", "dist-content")
|
||||
t.Chdir(root)
|
||||
|
||||
got, err := readSetupConfigTemplateYAML()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got != "dist-content" {
|
||||
t.Fatalf("readSetupConfigTemplateYAML() = %q, want dist-content", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadSetupConfigTemplateYAML_prefersFrontendPublic(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
writeSetupConfigYAML(t, root, "frontend/public/config.generated.yaml", "from-public")
|
||||
writeSetupConfigYAML(t, root, "internal/web/dist/config.generated.yaml", "from-dist")
|
||||
t.Chdir(root)
|
||||
|
||||
got, err := readSetupConfigTemplateYAML()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got != "from-public" {
|
||||
t.Fatalf("readSetupConfigTemplateYAML() = %q, want from-public", got)
|
||||
}
|
||||
}
|
||||
+19
-14
@@ -9,14 +9,13 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
_ "net/http/pprof"
|
||||
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/adapters/fs/fileutils"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/analytics"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/app"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/icons"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/preview"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/state"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/transcoding"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/utils"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/version"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/web"
|
||||
@@ -52,6 +51,12 @@ func initializeDatabase(configFile string, cliMode bool) bool {
|
||||
if err != nil {
|
||||
logger.Fatalf("could not initialize state: %v", err)
|
||||
}
|
||||
// state.Open applies persisted media settings, so initialize ffmpeg once here
|
||||
// (before wiring, which reads Env.FFmpegAvailable) instead of during config
|
||||
// load, which would run the multi-second hardware codec probe twice.
|
||||
if !cliMode {
|
||||
settings.InitFFmpeg()
|
||||
}
|
||||
runtimeApp, err = app.WireServices(store)
|
||||
if err != nil {
|
||||
logger.Fatalf("could not wire services: %v", err)
|
||||
@@ -87,14 +92,7 @@ func StartFilebrowser() {
|
||||
done := make(chan struct{}) // Signals server has stopped
|
||||
shutdownComplete := make(chan struct{}) // Signals shutdown process is complete
|
||||
|
||||
// Dev mode enables development features like template hot-reloading
|
||||
_, err := os.Stat("internal/web/dist")
|
||||
// In dev mode, always use filesystem assets. Otherwise, check if internal/web/dist exists
|
||||
if !settings.Env.IsDevMode {
|
||||
settings.Env.EmbeddedFs = os.IsNotExist(err)
|
||||
}
|
||||
|
||||
err = utils.SetInvalidPasswordHash()
|
||||
err := utils.SetInvalidPasswordHash()
|
||||
if err != nil {
|
||||
logger.Fatalf("Failed to set security hash: %v", err)
|
||||
}
|
||||
@@ -180,6 +178,13 @@ func StartFilebrowser() {
|
||||
fileutils.ClearCacheDir(settings.Config.Server.CacheDir)
|
||||
}
|
||||
<-shutdownComplete
|
||||
if transcodeMgr := transcoding.Default(); transcodeMgr != nil {
|
||||
shutdownCtx, shutdownCancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
if err := transcodeMgr.Close(shutdownCtx); err != nil {
|
||||
logger.Warningf("transcode shutdown: %v", err)
|
||||
}
|
||||
shutdownCancel()
|
||||
}
|
||||
if err := fileutils.ClearDirectoryContents(settings.DownloadCacheDir()); err != nil {
|
||||
logger.Warningf("failed to clear download spool on shutdown: %v", err)
|
||||
}
|
||||
@@ -194,14 +199,16 @@ func rootCMD(ctx context.Context, serverConfig *settings.Server, a *app.App, shu
|
||||
numWorkers := settings.Config.Server.NumImageProcessors
|
||||
|
||||
// Initialize asset filesystem before starting services
|
||||
if settings.Env.EmbeddedFs {
|
||||
if !settings.Env.IsDevMode && web.EmbeddedFrontendAvailable() {
|
||||
embeddedAssets := web.GetEmbeddedAssets()
|
||||
subAssets, err := fs.Sub(embeddedAssets, "embed")
|
||||
subAssets, err := fs.Sub(embeddedAssets, "dist")
|
||||
if err != nil {
|
||||
logger.Fatalf("Failed to create sub filesystem: %v", err)
|
||||
}
|
||||
settings.Env.EmbeddedFs = true
|
||||
fileutils.InitAssetFS(subAssets, true, false)
|
||||
} else {
|
||||
settings.Env.EmbeddedFs = false
|
||||
fileutils.InitAssetFS(nil, false, settings.Env.IsDevMode)
|
||||
}
|
||||
|
||||
@@ -210,8 +217,6 @@ func rootCMD(ctx context.Context, serverConfig *settings.Server, a *app.App, shu
|
||||
if err != nil {
|
||||
logger.Fatalf("Error starting preview service: %v", err)
|
||||
}
|
||||
logger.Debugf("MuPDF Enabled : %v", settings.Env.MuPdfAvailable)
|
||||
|
||||
// Generate PWA icons after preview service is initialized
|
||||
if err := icons.GeneratePWAIcons(); err != nil {
|
||||
logger.Warningf("Failed to generate PWA icons: %v", err)
|
||||
|
||||
@@ -62,3 +62,7 @@ userDefaults:
|
||||
#office:
|
||||
# url: "http://localhost:9052"
|
||||
# secret: "6H1H7GzUk2alRkNxAPav0W02g8JS5oUd"
|
||||
|
||||
integrations:
|
||||
media:
|
||||
skipHwCheck: true
|
||||
Binary file not shown.
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"generatedAt": "2026-10-27T14:46:52Z",
|
||||
"gitHead": "880900c18dc7655899398cfb7327ab4e191fc3f0",
|
||||
"profileSha256": "371d012d4ed5bc3907667f6d35876c998af98a6cc3c71f6ea4ddf57ab4ed4bbd",
|
||||
"workloads": [
|
||||
"internal/thumb BenchmarkMJPEGSmall/Large",
|
||||
"internal/thumb BenchmarkMP4H264Large",
|
||||
"internal/thumb BenchmarkMP4H264Small (full pipeline)",
|
||||
"internal/thumb BenchmarkMP4H264Baseline1080Small (CAVLC + thumb)",
|
||||
"internal/thumb BenchmarkMP4H264Main1080Large",
|
||||
"internal/thumb BenchmarkMP4H264High1080Large",
|
||||
"internal/thumb BenchmarkThumbnailLargeWebM",
|
||||
"internal/h264 BenchmarkBaselineThumbnailDecode (CAVLC IDR)"
|
||||
],
|
||||
"hotPathGlobs": [
|
||||
"internal/thumb/**/*.go",
|
||||
"internal/h264/**/*.go",
|
||||
"internal/kernels/**/*.go",
|
||||
"internal/isobmff/**/*.go",
|
||||
"internal/matroska/**/*.go",
|
||||
"internal/jpegfast/**/*.go"
|
||||
]
|
||||
}
|
||||
+20
-21
@@ -1,16 +1,17 @@
|
||||
module github.com/gtsteffaniak/filebrowser/backend
|
||||
|
||||
go 1.27.0
|
||||
go 1.27.1
|
||||
|
||||
require (
|
||||
github.com/alecthomas/kong v1.17.0
|
||||
github.com/asdine/storm/v3 v3.2.1
|
||||
github.com/cespare/xxhash/v2 v2.3.0
|
||||
github.com/coreos/go-oidc/v3 v3.21.0
|
||||
github.com/coreos/go-systemd/v22 v22.7.0
|
||||
github.com/dhowden/tag v0.0.0-20240417053706-3d75831295e8
|
||||
github.com/dsoprea/go-exif/v3 v3.0.1
|
||||
github.com/evanoberholster/imagemeta v1.1.0
|
||||
github.com/gen2brain/go-fitz v1.28.2
|
||||
github.com/gen2brain/folio v0.3.1
|
||||
github.com/go-ldap/ldap/v3 v3.4.15
|
||||
github.com/go-playground/validator/v10 v10.30.6
|
||||
github.com/go-webauthn/webauthn v0.18.2
|
||||
@@ -19,43 +20,47 @@ require (
|
||||
github.com/google/go-cmp v0.7.0
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/gtsteffaniak/go-cache v1.1.0
|
||||
github.com/gtsteffaniak/go-ffmpeg v1.6.2
|
||||
github.com/gtsteffaniak/go-ffmpeg v1.7.1
|
||||
github.com/gtsteffaniak/go-logger v1.1.0
|
||||
github.com/gtsteffaniak/go-media v1.3.2
|
||||
github.com/kovidgoyal/imaging v1.9.0
|
||||
github.com/mattn/go-sqlite3 v1.14.53
|
||||
github.com/pquerna/otp v1.5.0
|
||||
github.com/spf13/afero v1.15.0
|
||||
github.com/stretchr/testify v1.12.1
|
||||
github.com/swaggo/http-swagger v1.3.4
|
||||
github.com/swaggo/swag v1.16.6
|
||||
golang.org/x/crypto v0.59.0
|
||||
golang.org/x/image v0.48.0
|
||||
golang.org/x/mod v0.43.0
|
||||
golang.org/x/net v0.62.0
|
||||
golang.org/x/net v0.63.0
|
||||
golang.org/x/oauth2 v0.38.0
|
||||
golang.org/x/sync v0.25.0
|
||||
golang.org/x/sys v0.50.0
|
||||
golang.org/x/term v0.48.0
|
||||
golang.org/x/text v0.44.0
|
||||
golang.org/x/time v0.16.0
|
||||
golang.org/x/tools v0.52.0
|
||||
golang.org/x/tools v0.53.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
modernc.org/sqlite v1.62.0
|
||||
modernc.org/sqlite v1.63.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Azure/go-ntlmssp v0.1.1 // indirect
|
||||
github.com/KyleBanks/depth v1.2.1 // indirect
|
||||
github.com/boombuler/barcode v1.1.0 // indirect
|
||||
github.com/abema/go-mp4 v1.7.4 // indirect
|
||||
github.com/boombuler/barcode v1.1.1 // indirect
|
||||
github.com/dsoprea/go-logging v0.0.0-20200710184922-b02d349568dd // indirect
|
||||
github.com/dsoprea/go-utility/v2 v2.0.0-20221003172846-a3e1774ef349 // indirect
|
||||
github.com/dustin/go-humanize v1.1.0 // indirect
|
||||
github.com/ebitengine/purego v0.11.3 // indirect
|
||||
github.com/fxamacker/cbor/v2 v2.10.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.16 // indirect
|
||||
github.com/gen2brain/gav1d v0.2.10 // indirect
|
||||
github.com/gen2brain/h265 v0.2.7 // indirect
|
||||
github.com/gen2brain/jxl v0.2.2 // indirect
|
||||
github.com/gen2brain/vpx v0.2.3 // indirect
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.8 // indirect
|
||||
github.com/go-errors/errors v1.5.1 // indirect
|
||||
github.com/go-jose/go-jose/v4 v4.1.9 // indirect
|
||||
github.com/go-openapi/jsonpointer v1.0.2 // indirect
|
||||
github.com/go-openapi/jsonpointer v1.0.3 // indirect
|
||||
github.com/go-openapi/jsonreference v1.0.3 // indirect
|
||||
github.com/go-openapi/spec v1.0.1 // indirect
|
||||
github.com/go-openapi/swag/conv v0.29.2 // indirect
|
||||
@@ -68,12 +73,13 @@ require (
|
||||
github.com/go-playground/locales v0.14.2 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.2 // indirect
|
||||
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
|
||||
github.com/go-webauthn/x v0.3.1 // indirect
|
||||
github.com/go-webauthn/x v0.4.1 // indirect
|
||||
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
|
||||
github.com/golang/geo v0.0.0-20261106073233-5e8d6967632a // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/google/go-tpm v0.9.8 // indirect
|
||||
github.com/gtsteffaniak/go-vpx v1.0.1 // indirect
|
||||
github.com/kovidgoyal/go-parallel v1.1.1 // indirect
|
||||
github.com/kovidgoyal/go-shm v1.0.0 // indirect
|
||||
github.com/kr/pretty v0.3.1 // indirect
|
||||
@@ -85,22 +91,15 @@ require (
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
github.com/rogpeppe/go-internal v1.16.0 // indirect
|
||||
github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd // indirect
|
||||
github.com/swaggo/files v1.0.1 // indirect
|
||||
github.com/tinylib/msgp v1.6.5 // indirect
|
||||
github.com/x448/float16 v0.8.4 // indirect
|
||||
go.etcd.io/bbolt v1.5.0 // indirect
|
||||
go.yaml.in/yaml/v3 v3.0.6 // indirect
|
||||
golang.org/x/sync v0.25.0 // indirect
|
||||
google.golang.org/appengine v1.6.8 // indirect
|
||||
google.golang.org/protobuf v1.36.12 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
modernc.org/libc v1.81.0 // indirect
|
||||
modernc.org/libc v1.82.13 // indirect
|
||||
modernc.org/mathutil v1.7.1 // indirect
|
||||
modernc.org/memory v1.12.1 // indirect
|
||||
)
|
||||
|
||||
exclude (
|
||||
github.com/alecthomas/go-check-sumtype v0.5.0
|
||||
github.com/gtsteffaniak/go-ffmpeg v1.1.0
|
||||
modernc.org/memory v1.13.0 // indirect
|
||||
)
|
||||
+57
-40
@@ -6,6 +6,8 @@ github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc
|
||||
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
|
||||
github.com/Sereal/Sereal v0.0.0-20190618215532-0b8ac451a863 h1:BRrxwOZBolJN4gIwvZMJY1tzqBvQgpaZiQRuIDD40jM=
|
||||
github.com/Sereal/Sereal v0.0.0-20190618215532-0b8ac451a863/go.mod h1:D0JMgToj/WdxCgd30Kc1UcA9E+WdZoJqeVOuYW7iTBM=
|
||||
github.com/abema/go-mp4 v1.7.4 h1:MztDjMx3nac+Lktig9wrUa962Mnyi4+ZtDtpbHuckww=
|
||||
github.com/abema/go-mp4 v1.7.4/go.mod h1:vPl9t5ZK7K0x68jh12/+ECWBCXoWuIDtNgPtU2f04ws=
|
||||
github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0=
|
||||
github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
|
||||
github.com/alecthomas/kong v1.17.0 h1:f52BVWChYMDkMkCoqkEWRuFOk/K4B5LO7xIijeLJRdk=
|
||||
@@ -17,12 +19,15 @@ github.com/alexbrainman/sspi v0.0.0-20250919150558-7d374ff0d59e/go.mod h1:cEWa1L
|
||||
github.com/asdine/storm/v3 v3.2.1 h1:I5AqhkPK6nBZ/qJXySdI7ot5BlXSZ7qvDY1zAn5ZJac=
|
||||
github.com/asdine/storm/v3 v3.2.1/go.mod h1:LEpXwGt4pIqrE/XcTvCnZHT5MgZCV6Ub9q7yQzOFWr0=
|
||||
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
|
||||
github.com/boombuler/barcode v1.1.0 h1:ChaYjBR63fr4LFyGn8E8nt7dBSt3MiU3zMOZqFvVkHo=
|
||||
github.com/boombuler/barcode v1.1.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
|
||||
github.com/boombuler/barcode v1.1.1 h1:L7a025eARYfC7mcb3RblJnqeyWsYBuOEMWP3CauuqkA=
|
||||
github.com/boombuler/barcode v1.1.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/coreos/go-oidc/v3 v3.21.0 h1:wZo4Q9Pum8dYEj0eMUPrqR+kvuGkeUplbLpNCkBqoWM=
|
||||
github.com/coreos/go-oidc/v3 v3.21.0/go.mod h1:DYCf24+ncYi+XkIH97GY1+dqoRlbaSI26KVTCI9SrY4=
|
||||
github.com/coreos/go-systemd/v22 v22.7.0 h1:LAEzFkke61DFROc7zNLX/WA2i5J8gYqe0rSj9KI28KA=
|
||||
github.com/coreos/go-systemd/v22 v22.7.0/go.mod h1:xNUYtjHu2EDXbsxz1i41wouACIwT7Ybq9o0BQhMwD0w=
|
||||
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
@@ -47,16 +52,22 @@ github.com/dsoprea/go-utility/v2 v2.0.0-20221003172846-a3e1774ef349 h1:DilThiXje
|
||||
github.com/dsoprea/go-utility/v2 v2.0.0-20221003172846-a3e1774ef349/go.mod h1:4GC5sXji84i/p+irqghpPFZBF8tRN/Q7+700G0/DLe8=
|
||||
github.com/dustin/go-humanize v1.1.0 h1:dbKTrvD0klcbBV/h4AWJdMuZogJACoMlvWIWZ5b2xWg=
|
||||
github.com/dustin/go-humanize v1.1.0/go.mod h1:hc1CvRkJMsgxqjmjMQF3QNRAZBwY8AXBAzKYoSX9sFI=
|
||||
github.com/ebitengine/purego v0.11.3 h1:OB+JLpdm7ioymhyA+6s5kbb/uOuYycAgL8NNTFc5MLg=
|
||||
github.com/ebitengine/purego v0.11.3/go.mod h1:DCHPP08djqhNSoTfImcnHYQRZmd0qhakvrozqaEYhGQ=
|
||||
github.com/evanoberholster/imagemeta v1.1.0 h1:0iBtgVxLORZTZAlKxRcNodBmjMfHCSFwUh8Asmi83oI=
|
||||
github.com/evanoberholster/imagemeta v1.1.0/go.mod h1:nmf6le+qSyoRAXgp2psPbtfkxcEgf/AZGgai9pnN8d0=
|
||||
github.com/fxamacker/cbor/v2 v2.10.0 h1:HVF3T5vYwLqO81ebPirWEPNv2SMrUMD3HLnKgEr6uWE=
|
||||
github.com/fxamacker/cbor/v2 v2.10.0/go.mod h1:uSwlToFuT9BZAKRxxVm3qQC8DR4tlWl7D6pf20iRYH4=
|
||||
github.com/gabriel-vasile/mimetype v1.4.16 h1:5izNFuvA37st1dDRAcA7TtmngBmRgiIPDmTtiEvjx1E=
|
||||
github.com/gabriel-vasile/mimetype v1.4.16/go.mod h1:3oFFwxX8kTklZwzIl2aQEDZT0lKY8xH92ST88bAwba4=
|
||||
github.com/gen2brain/go-fitz v1.28.2 h1:845G85N5TUgnq5oDqyYrW0JvehAkeo35UkkK2dJtW1M=
|
||||
github.com/gen2brain/go-fitz v1.28.2/go.mod h1:pY2hqAjp9Zy7qfPI2gwbJMHBFAdZpVXOLrRxD82l3Bs=
|
||||
github.com/gen2brain/folio v0.3.1 h1:R6JEt3+h3F3jX/rUCL4UM+v9mx7/cwIgKkf6n3jOiU8=
|
||||
github.com/gen2brain/folio v0.3.1/go.mod h1:m8y2W5N5arjEiZ3O7UI27XaJnhELoPsjn1vWKYF3gms=
|
||||
github.com/gen2brain/gav1d v0.2.10 h1:27Qhi4hgaaoh4Nkv3ZbG6WG9aT+QQUuiWnh+UiBb2PQ=
|
||||
github.com/gen2brain/gav1d v0.2.10/go.mod h1:5tgr8NUHPGhwU8PcIMDnP1iESRIsxYRgm/HAUg8WwlY=
|
||||
github.com/gen2brain/h265 v0.2.7 h1:PGGRPSZ5K0RsKhmk7UBk+j55HtWh/8mJgJk4ns8U3ho=
|
||||
github.com/gen2brain/h265 v0.2.7/go.mod h1:xR/WG8zUmzFC4GpeiRwBX/ERtlu3hamQcAgD76/8rcI=
|
||||
github.com/gen2brain/jxl v0.2.2 h1:Lq2F88CkWIPmhUIANthY3W2UfYMeq7NjciKnNC9c6qU=
|
||||
github.com/gen2brain/jxl v0.2.2/go.mod h1:8TXnWS8wDSmYunyyhUgl5LYPiBsrWIDD02OmgOMFtrE=
|
||||
github.com/gen2brain/vpx v0.2.3 h1:ywoNilxbHh6b+OaN67E+IylL/IsgjfSoUd90HXY5A3A=
|
||||
github.com/gen2brain/vpx v0.2.3/go.mod h1:637bQw2nk+PKT34NnIaZTzHeUWkIFReUn9S/4szqS6M=
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.8 h1:H9AZkK22UOmfX8J84ubyaZxKJZ3FMHVwn8swoMML7iQ=
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.8/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
|
||||
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
|
||||
@@ -69,8 +80,8 @@ github.com/go-jose/go-jose/v4 v4.1.9 h1:pKfeQkig1NmgK4hJrZYXLEYURXfoJB61Larw0uIW
|
||||
github.com/go-jose/go-jose/v4 v4.1.9/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08=
|
||||
github.com/go-ldap/ldap/v3 v3.4.15 h1:eRB4f4Ecn1POL1mO86+uUDlecmyWsdiJwh60bAUS4UY=
|
||||
github.com/go-ldap/ldap/v3 v3.4.15/go.mod h1:jeD0c98EdZQCKKKKe4kTWs5aCf6y+j8KuYsYLznZSQk=
|
||||
github.com/go-openapi/jsonpointer v1.0.2 h1:NbW7xT2b+l7x+JefiPGDsZWsrLk1ogrz4AHK1TTzMt8=
|
||||
github.com/go-openapi/jsonpointer v1.0.2/go.mod h1:N0rI4MbNKD7xAFTiHtB+5Nhrg2j/wwYg7m7Fmb4/jk8=
|
||||
github.com/go-openapi/jsonpointer v1.0.3 h1:iEtrz/inxw+0za5lr10whyxplQdwJruNoQAFA6Sogso=
|
||||
github.com/go-openapi/jsonpointer v1.0.3/go.mod h1:rf2X/7HDNST8NkSpeV5gTOJeCZXwcIHyVbr5CPiWSDU=
|
||||
github.com/go-openapi/jsonreference v1.0.3 h1:5rDbq+JsjCv6/nUDDJt83nLZoADI4w03uvHXer+4aYQ=
|
||||
github.com/go-openapi/jsonreference v1.0.3/go.mod h1:OJSlMXHysgH272D9z2tiy2MGe5A9vQLHaCPb6KbYdE4=
|
||||
github.com/go-openapi/spec v1.0.1 h1:lj2vdGpNDcVgwRc6qXdw6qt/KQpCtSa9tnUH6vpDPDk=
|
||||
@@ -94,8 +105,8 @@ github.com/go-openapi/swag/yamlutils v0.29.2 h1:IFKFFeDnuIwzfsuWRQU+rI8iL3g4XyAY
|
||||
github.com/go-openapi/swag/yamlutils v0.29.2/go.mod h1:7MGqtcrK73sxQ4ceiyIf8qiXS/s09JLMdR5esK5euYQ=
|
||||
github.com/go-openapi/testify/enable/yaml/v2 v2.7.0 h1:wPW6YRgx3+SID1yUy/Xwa17L8kFEaEKod2VRbJDZNUs=
|
||||
github.com/go-openapi/testify/enable/yaml/v2 v2.7.0/go.mod h1:mI1M88etYbc3PhgHsWQK2kwvNwW5aGFqMPbmib+SGIs=
|
||||
github.com/go-openapi/testify/v2 v2.8.0 h1:19QDx5b57p8KjO2E4sgs/woL4Akp+FGLRlVm2xn0Rho=
|
||||
github.com/go-openapi/testify/v2 v2.8.0/go.mod h1:4gUN8jC+RqOE2qjW/vDmfyTvl5BCht4qL7oca0odrak=
|
||||
github.com/go-openapi/testify/v2 v2.8.1 h1:zk3S6KaDY1iQW91vsOJc25Ql1xm5bhPrZKdnL930bRQ=
|
||||
github.com/go-openapi/testify/v2 v2.8.1/go.mod h1:4gUN8jC+RqOE2qjW/vDmfyTvl5BCht4qL7oca0odrak=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.2 h1:d8UmcrM6Nip0hfGZKLGpAvZH37XB4TS0xzK9B56YNCY=
|
||||
@@ -108,8 +119,8 @@ github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPE
|
||||
github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
|
||||
github.com/go-webauthn/webauthn v0.18.2 h1:0BeftmEHU7i3Dv0VFwBtidy/ba37Vcdjvqst9EYu8Sk=
|
||||
github.com/go-webauthn/webauthn v0.18.2/go.mod h1:hEXaOuLxvZ3zG9miZe3ehlyeVso9AtklXG+kTn36k+A=
|
||||
github.com/go-webauthn/x v0.3.1 h1:1ff37z3XfmTTomkhlURgGizLIDyOvPgTt2t9nlzKLRo=
|
||||
github.com/go-webauthn/x v0.3.1/go.mod h1:ZInxAynYXfBPvvm5gzKZ7geBlL23K71xASMgohHl/Rg=
|
||||
github.com/go-webauthn/x v0.4.1 h1:zOZMFgQIHg3gHOHiGCEkFhc9ZYbDnMw+d4XXq+rpoIA=
|
||||
github.com/go-webauthn/x v0.4.1/go.mod h1:8MN6mqQWQzNSwJdw8j7nvkrGl2rACldz91oqKsImQQ8=
|
||||
github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM=
|
||||
github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
|
||||
github.com/golang-jwt/jwt/v4 v4.5.2 h1:YtQM7lnr8iZ+j5q71MGKkNw9Mn7AjHM68uc9g5fXeUI=
|
||||
@@ -139,14 +150,19 @@ github.com/google/go-tpm-tools v0.3.13-0.20230620182252-4639ecce2aba h1:qJEJcuLz
|
||||
github.com/google/go-tpm-tools v0.3.13-0.20230620182252-4639ecce2aba/go.mod h1:EFYHy8/1y2KfgTAsx7Luu7NGhoxtuVHnNo8jE7FikKc=
|
||||
github.com/google/pprof v0.0.0-20261016150608-1facf8f91b50 h1:PlNWJRxu5APSV0pWqfIsZ0qt9OOGHSWfZQ4zvx+WgWs=
|
||||
github.com/google/pprof v0.0.0-20261016150608-1facf8f91b50/go.mod h1:yUo1AMMpsPIDFGuwDK8nLcf8+vvAd5l2O6JDZ6hpwrM=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gtsteffaniak/go-cache v1.1.0 h1:ni/2cJpCxpGmaMZd92iTDIGOy+yUcMcxQuW7bSKhkCE=
|
||||
github.com/gtsteffaniak/go-cache v1.1.0/go.mod h1:rHUZvf4huhMX/bnNK4/oQ3sNAE2fYC2jFpAWZiBPWac=
|
||||
github.com/gtsteffaniak/go-ffmpeg v1.6.2 h1:gtvBg3G4PHO1Z/ZIPEK/XP4XT/g+l9S0Rpmmq6v5tnA=
|
||||
github.com/gtsteffaniak/go-ffmpeg v1.6.2/go.mod h1:FefhoD+KZzHWqBaUpntcKp6lXtUzdFW00F74axnENUQ=
|
||||
github.com/gtsteffaniak/go-ffmpeg v1.7.1 h1:XXfz0/VpYdZqgrYg4DoeSWqkdXvCoRkR6JwhLU1M/nY=
|
||||
github.com/gtsteffaniak/go-ffmpeg v1.7.1/go.mod h1:FefhoD+KZzHWqBaUpntcKp6lXtUzdFW00F74axnENUQ=
|
||||
github.com/gtsteffaniak/go-logger v1.1.0 h1:baFds+iibuLLNpNLwygz32bDqdsunI6dGWcdxwMIVKI=
|
||||
github.com/gtsteffaniak/go-logger v1.1.0/go.mod h1:rapapTju4D7bwt6h4JOdZNUXDjnp0WkTBd6TN5yWglI=
|
||||
github.com/gtsteffaniak/go-media v1.3.2 h1:V+NBnRwsTTvGxBLQfhx9/LlDmnjbBgX4AKsQ3UOH6b0=
|
||||
github.com/gtsteffaniak/go-media v1.3.2/go.mod h1:OqnFJYum+7At6bdiv7vSO1iJDYp7u6zke+DjF4TQXBs=
|
||||
github.com/gtsteffaniak/go-vpx v1.0.1 h1:9lSI8yoz6omDChaeV0AJrhdfe2YTrWvJrDENI/bnkAM=
|
||||
github.com/gtsteffaniak/go-vpx v1.0.1/go.mod h1:tRCdDZ15oZZTsiwmQAwyH56PTt1jn1C1O0P03oOkoJ8=
|
||||
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
|
||||
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
|
||||
@@ -178,6 +194,7 @@ github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
@@ -185,10 +202,10 @@ github.com/leodido/go-urn v1.5.0 h1:pLqT2kq1zpHW/1D18QMjMpdtX7cekxqtJJjg5ANyWw0=
|
||||
github.com/leodido/go-urn v1.5.0/go.mod h1:9BORnCDhdPBJNDEX+w1bJisa8yOKYi116VeO96s4ifE=
|
||||
github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI=
|
||||
github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A=
|
||||
github.com/mattn/go-sqlite3 v1.14.53 h1:mnTM0owzUMrKuLo+0w51NUiB0ir2Fo7kFXlPt/l3BGs=
|
||||
github.com/mattn/go-sqlite3 v1.14.53/go.mod h1:6JTjA44L93a0QCyJef5YvlPoKXntQPjzWv5gtm9sB6w=
|
||||
github.com/ncruces/go-strftime v1.1.0 h1:vtPmPWMkb539RGV9WpWT9EwJGvrOCKvMNI4obWL47Hk=
|
||||
github.com/ncruces/go-strftime v1.1.0/go.mod h1:yVaq7iwCN09vHRrKBrrflXT0M9tTMG2KmZ9Fj7xeG/g=
|
||||
github.com/orcaman/writerseeker v0.0.0-20200621085525-1d3f536ff85e h1:s2RNOM/IGdY0Y6qfTeUKhDawdHDpK9RGBdx80qN4Ttw=
|
||||
github.com/orcaman/writerseeker v0.0.0-20200621085525-1d3f536ff85e/go.mod h1:nBdnFKj15wFbf94Rwfq4m30eAcyY9V/IyKAGQFtqkW0=
|
||||
github.com/philhofer/fwd v1.2.1 h1:UtpS73q8bFgy/yH3gCq8LSNvj5gv/FowNOiWZa7uKwQ=
|
||||
github.com/philhofer/fwd v1.2.1/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM=
|
||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||
@@ -209,12 +226,10 @@ github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE=
|
||||
github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
|
||||
github.com/swaggo/files v1.0.1 h1:J1bVJ4XHZNq0I46UU90611i9/YzdrF7x92oX1ig5IdE=
|
||||
github.com/swaggo/files v1.0.1/go.mod h1:0qXmMNH6sXNf+73t65aKeB+ApmgxdnkQzVTAj2uaMUg=
|
||||
github.com/swaggo/http-swagger v1.3.4 h1:q7t/XLx0n15H1Q9/tk3Y9L4n210XzJF5WtnDX64a5ww=
|
||||
github.com/swaggo/http-swagger v1.3.4/go.mod h1:9dAh0unqMBAlbp1uE2Uc2mQTxNMU/ha4UbucIg1MFkQ=
|
||||
github.com/sunfish-shogi/bufseekio v0.0.0-20210207115823-a4185644b365/go.mod h1:dEzdXgvImkQ3WLI+0KQpmEx8T/C/ma9KeS3AfmU899I=
|
||||
github.com/swaggo/swag v1.16.6 h1:qBNcx53ZaX+M5dxVyTrgQ0PJ/ACK+NzhwcbieTt+9yI=
|
||||
github.com/swaggo/swag v1.16.6/go.mod h1:ngP2etMK5a0P3QBizic5MEwpRmluJZPHjXcMoj4Xesg=
|
||||
github.com/tinylib/msgp v1.6.5 h1:iAH6XTP7BpzErjBZlujJQXxA+GmRi2YWs6M4KdLtNbE=
|
||||
@@ -250,9 +265,8 @@ golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.0.0-20221002022538-bcab6841153b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.62.0 h1:18ELalfM5+XNRwzM2nYqXsZQ9ByS1uhj2O/U7+5jqRY=
|
||||
golang.org/x/net v0.62.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI=
|
||||
golang.org/x/net v0.63.0 h1:HCoTmNh9EpD1PpK8gBNFY4gcTY4N+KQEO8ylfIKqFJ0=
|
||||
golang.org/x/net v0.63.0/go.mod h1:15JLg3IX1bLjHK264EZQEbIpTiR/KVLuo9CTRWd0pig=
|
||||
golang.org/x/oauth2 v0.38.0 h1:uW7XQbcu1eoiQS7uMJvLOjPMl04bTbmY1VeRPxvbspI=
|
||||
golang.org/x/oauth2 v0.38.0/go.mod h1:IxwZNxUULJmpBFf9K/9NTMSIfZZuvuTy1gGxhigP/58=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@@ -260,6 +274,7 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ
|
||||
golang.org/x/sync v0.25.0 h1:dJnifr0nMV8/SBnBvdo4eSGGnrc3O4FFx6IqvtLcmRs=
|
||||
golang.org/x/sync v0.25.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@@ -269,12 +284,10 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.50.0 h1:dkKZEFTEKaLr1sjhs0WiKqoi8Jj5nHbS3Njmx1UoMJs=
|
||||
golang.org/x/sys v0.50.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.48.0 h1:G6UU1eiSB8nl3DzeUGt7Mg+2SctI8tPS6Z5/mBt6cOk=
|
||||
golang.org/x/term v0.48.0/go.mod h1:BRDLHCZr2SUjIeBHHpRyQeC9xzSAVbzY2rvKgafnHf4=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
@@ -282,7 +295,6 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.44.0 h1:YItdp/mQNGnsmrgpcdA5yQ3bnRxCfo/Tj/iByGW9GGo=
|
||||
golang.org/x/text v0.44.0/go.mod h1:S4FR1waQ9LbjQTls97SyRjDaUUVkaM+cXwwuG/G+MwY=
|
||||
golang.org/x/time v0.16.0 h1:vMb6ptszcQMkcwiRTAuNNU50gom6++Q/6gY2hDM6VDE=
|
||||
@@ -290,8 +302,8 @@ golang.org/x/time v0.16.0/go.mod h1:rVKOqvZeKvrDKTQiAHJ7wmwP0RzleSphoEA9RcdLA0s=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.52.0 h1:ryxg4U63oaUYk7uOLTF37n43f4qgtGvqV4Ioit1BaEs=
|
||||
golang.org/x/tools v0.52.0/go.mod h1:ItcP5UNaVGG+Yc4eIYmaFLNJ4soEopkx5Y2d4lcEurs=
|
||||
golang.org/x/tools v0.53.0 h1:T3bIVp3zjHG9/aEiFk6BXxFh5/Vcbk7JA5hRq1cG8IU=
|
||||
golang.org/x/tools v0.53.0/go.mod h1:vg+Vrb7y5mTTtxZLTdbTK8G745wcaLcsCtgCWgQONCI=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
@@ -302,39 +314,44 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
|
||||
google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc=
|
||||
google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/src-d/go-billy.v4 v4.3.2 h1:0SQA1pRztfTFx2miS8sA97XvooFeNOmvUenF4o0EcVg=
|
||||
gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
modernc.org/cc/v4 v4.34.0 h1:ooKvVkbVJApIi1dVGl9R0cxQz+UKixXd+zjUH6l8af0=
|
||||
modernc.org/cc/v4 v4.34.0/go.mod h1:OnovgIhbbMXMu1aISnJ0wvVD1KnW+cAUJkIrAWh+kVI=
|
||||
modernc.org/ccgo/v4 v4.39.0 h1:Dk2UbgzY/DwlSKNHAJeO1hxGkkjiY3S1sgqSCrlDhzU=
|
||||
modernc.org/ccgo/v4 v4.39.0/go.mod h1:/0Re1N2uIR+YRP3B57BDD2XW+zUAnxqlT5GZfSP+vBE=
|
||||
modernc.org/cc/v4 v4.35.0 h1:10xacwrazYm2sXXVAh5JaVv/6s0oDvcAdii60xqrMlU=
|
||||
modernc.org/cc/v4 v4.35.0/go.mod h1:OnovgIhbbMXMu1aISnJ0wvVD1KnW+cAUJkIrAWh+kVI=
|
||||
modernc.org/ccgo/v4 v4.39.3 h1:Q05YQC26r2I81gXFccLG9W4WjAJ2/Cww1fkJjc9QRXw=
|
||||
modernc.org/ccgo/v4 v4.39.3/go.mod h1:/0Re1N2uIR+YRP3B57BDD2XW+zUAnxqlT5GZfSP+vBE=
|
||||
modernc.org/fileutil v1.4.0 h1:j6ZzNTftVS054gi281TyLjHPp6CPHr2KCxEXjEbD6SM=
|
||||
modernc.org/fileutil v1.4.0/go.mod h1:EqdKFDxiByqxLk8ozOxObDSfcVOv/54xDs/DUHdvCUU=
|
||||
modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=
|
||||
modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
|
||||
modernc.org/gc/v3 v3.2.0 h1:/Y3LGDMQaoYf55PebP1qsZ5FDGgAZyG1RYKEHeQzh1o=
|
||||
modernc.org/gc/v3 v3.2.0/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY=
|
||||
modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks=
|
||||
modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
|
||||
modernc.org/libc v1.81.0 h1:Kx11pb+4ETDPgkN9P6nHNTeVfrS+1w46LoIDbYcZEtM=
|
||||
modernc.org/libc v1.81.0/go.mod h1:xlOEexcpOVlRiVw/CDpTqkXxG2uXXGF4i8uR7BAM9sY=
|
||||
modernc.org/goabi0 v0.2.1 h1:3pes1FdZWxqXYzQzhqx9rUrcCWpAc5BqHSBNFaCNqDU=
|
||||
modernc.org/goabi0 v0.2.1/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
|
||||
modernc.org/libc v1.82.13 h1:6eRnkBHSoEKKDnDTr2sYvpNBbvoNWjjUK0J8JfaB9cA=
|
||||
modernc.org/libc v1.82.13/go.mod h1:rjCYooDr4MHEk48eYWZZbRsxEBkCFu7fBiS8FPi7K2Q=
|
||||
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
|
||||
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
|
||||
modernc.org/memory v1.12.1 h1:nFMiWrpStgZczNl6XI9GnIk/rWhYIyHGUaR04pGbp9g=
|
||||
modernc.org/memory v1.12.1/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
|
||||
modernc.org/memory v1.13.0 h1:w9OBwQd9VNvf8vA+KRBf+Es0TFCGcQsXvRiOVpbRfAY=
|
||||
modernc.org/memory v1.13.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
|
||||
modernc.org/opt v0.2.0 h1:tGyef5ApycA7FSEOMraay9SaTk5zmbx7Tu+cJs4QKZg=
|
||||
modernc.org/opt v0.2.0/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
|
||||
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
|
||||
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
|
||||
modernc.org/sqlite v1.62.0 h1:gMaCjSM1qpl+iOjiWhR1LYP3zqrYDI+5GYLGt6veP2g=
|
||||
modernc.org/sqlite v1.62.0/go.mod h1:Jzjh1mt4s0HuQ0KvtB1LIuHiGRmU2D5pgj8dUhW7/SE=
|
||||
modernc.org/sqlite v1.63.0 h1:ClxazqRFNfr7XPHTVLbyzTVz2PjWPz+BfJNu2e8JDMs=
|
||||
modernc.org/sqlite v1.63.0/go.mod h1:Jzjh1mt4s0HuQ0KvtB1LIuHiGRmU2D5pgj8dUhW7/SE=
|
||||
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
|
||||
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
|
||||
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
|
||||
|
||||
@@ -14,13 +14,13 @@ func TestUserUpdateChangesSkipsSensitiveFields(t *testing.T) {
|
||||
FrontendUser: users.FrontendUser{
|
||||
Username: "alice",
|
||||
NonAdminEditable: users.NonAdminEditable{
|
||||
DarkMode: true,
|
||||
DarkMode: users.DarkModeDark,
|
||||
},
|
||||
},
|
||||
TOTPSecret: "secret-value",
|
||||
}
|
||||
after := *before
|
||||
after.DarkMode = false
|
||||
after.DarkMode = users.DarkModeLight
|
||||
after.TOTPSecret = "new-secret"
|
||||
|
||||
changes := UserUpdateChanges(before, &after, []string{"totpSecret", "darkMode"}, false)
|
||||
@@ -36,7 +36,7 @@ func TestUserUpdateChangesFiltersUnchangedFields(t *testing.T) {
|
||||
FrontendUser: users.FrontendUser{
|
||||
Username: "akadmin",
|
||||
NonAdminEditable: users.NonAdminEditable{
|
||||
DarkMode: true,
|
||||
DarkMode: users.DarkModeDark,
|
||||
StickySidebar: true,
|
||||
Locale: "en",
|
||||
SingleClick: false,
|
||||
@@ -47,7 +47,7 @@ func TestUserUpdateChangesFiltersUnchangedFields(t *testing.T) {
|
||||
},
|
||||
}
|
||||
after := *before
|
||||
after.DarkMode = false
|
||||
after.DarkMode = users.DarkModeLight
|
||||
after.Sorting = users.Sorting{By: "name", Asc: true}
|
||||
|
||||
which := []string{
|
||||
@@ -60,7 +60,7 @@ func TestUserUpdateChangesFiltersUnchangedFields(t *testing.T) {
|
||||
if len(changes) != 3 {
|
||||
t.Fatalf("expected 3 changes, got %d: %#v", len(changes), changes)
|
||||
}
|
||||
if changes[0].Field != "darkMode" || changes[0].From != "true" || changes[0].To != "false" {
|
||||
if changes[0].Field != "darkMode" || changes[0].From != "dark" || changes[0].To != "light" {
|
||||
t.Fatalf("unexpected darkMode change: %#v", changes[0])
|
||||
}
|
||||
if changes[1].Field != "sorting.asc" || changes[1].From != "false" || changes[1].To != "true" {
|
||||
@@ -141,6 +141,14 @@ func TestUserUpdateChangesExpandsNestedStructFields(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Mock source paths used only as lookup keys in tests. They never touch the
|
||||
// filesystem. They are relative (and not equal to the source names) so the
|
||||
// tests are portable across machines.
|
||||
const (
|
||||
testDownloadsPath = "./testdata/Downloads"
|
||||
testAccessPath = "./testdata/playwright-files"
|
||||
)
|
||||
|
||||
type activityChangePair struct {
|
||||
from string
|
||||
to string
|
||||
@@ -150,9 +158,9 @@ func testDownloadsSourceConfig() *users.SourceConfigProvider {
|
||||
return &users.SourceConfigProvider{
|
||||
GetSourceByPath: func(path string) (users.SourceInfo, bool) {
|
||||
switch path {
|
||||
case "/Users/steffag/Downloads":
|
||||
case testDownloadsPath:
|
||||
return users.SourceInfo{Path: path, Name: "Downloads"}, true
|
||||
case "/Users/steffag/git/personal/filebrowser/frontend/tests/playwright-files":
|
||||
case testAccessPath:
|
||||
return users.SourceInfo{Path: path, Name: "access"}, true
|
||||
default:
|
||||
return users.SourceInfo{}, false
|
||||
@@ -229,8 +237,8 @@ func TestUserUpdateChangesExpandsPreviewBulkToggle(t *testing.T) {
|
||||
func TestUserUpdateChangesExpandsBackendSourcePermissions(t *testing.T) {
|
||||
withTestSourceConfig(t, testDownloadsSourceConfig())
|
||||
|
||||
downloadsPath := "/Users/steffag/Downloads"
|
||||
accessPath := "/Users/steffag/git/personal/filebrowser/frontend/tests/playwright-files"
|
||||
downloadsPath := testDownloadsPath
|
||||
accessPath := testAccessPath
|
||||
beforePerms := users.MarkSourceFilePermissionsConfigured(users.SourceFilePermissions{
|
||||
View: true, Download: true,
|
||||
})
|
||||
@@ -274,8 +282,8 @@ func TestUserUpdateChangesExpandsBackendSourcePermissions(t *testing.T) {
|
||||
func TestUserUpdateChangesExpandsScopePermissions(t *testing.T) {
|
||||
withTestSourceConfig(t, testDownloadsSourceConfig())
|
||||
|
||||
downloadsPath := "/Users/steffag/Downloads"
|
||||
accessPath := "/Users/steffag/git/personal/filebrowser/frontend/tests/playwright-files"
|
||||
downloadsPath := testDownloadsPath
|
||||
accessPath := testAccessPath
|
||||
basePerms := users.MarkSourceFilePermissionsConfigured(users.SourceFilePermissions{
|
||||
View: true, Download: true,
|
||||
})
|
||||
@@ -353,9 +361,9 @@ func TestSidebarLinksFieldChangeIgnoresPathVsName(t *testing.T) {
|
||||
withTestSourceConfig(t, &users.SourceConfigProvider{
|
||||
GetSourceByPath: func(path string) (users.SourceInfo, bool) {
|
||||
switch path {
|
||||
case "/Users/steffag/Downloads":
|
||||
case testDownloadsPath:
|
||||
return users.SourceInfo{Path: path, Name: "Downloads"}, true
|
||||
case "/Users/steffag/git/personal/filebrowser/frontend/tests/playwright-files":
|
||||
case testAccessPath:
|
||||
return users.SourceInfo{Path: path, Name: "access"}, true
|
||||
default:
|
||||
return users.SourceInfo{}, false
|
||||
@@ -364,9 +372,9 @@ func TestSidebarLinksFieldChangeIgnoresPathVsName(t *testing.T) {
|
||||
GetSourceByName: func(name string) (users.SourceInfo, bool) {
|
||||
switch name {
|
||||
case "Downloads":
|
||||
return users.SourceInfo{Path: "/Users/steffag/Downloads", Name: "Downloads"}, true
|
||||
return users.SourceInfo{Path: testDownloadsPath, Name: "Downloads"}, true
|
||||
case "access":
|
||||
return users.SourceInfo{Path: "/Users/steffag/git/personal/filebrowser/frontend/tests/playwright-files", Name: "access"}, true
|
||||
return users.SourceInfo{Path: testAccessPath, Name: "access"}, true
|
||||
default:
|
||||
return users.SourceInfo{}, false
|
||||
}
|
||||
@@ -380,8 +388,8 @@ func TestSidebarLinksFieldChangeIgnoresPathVsName(t *testing.T) {
|
||||
ShowToolsInSidebar: true,
|
||||
SidebarLinks: []users.SidebarLink{
|
||||
toolsLink,
|
||||
{Name: "Downloads", Category: "source", Target: "/", SourceName: "/Users/steffag/Downloads"},
|
||||
{Name: "access", Category: "source", Target: "/", SourceName: "/Users/steffag/git/personal/filebrowser/frontend/tests/playwright-files"},
|
||||
{Name: "Downloads", Category: "source", Target: "/", SourceName: testDownloadsPath},
|
||||
{Name: "access", Category: "source", Target: "/", SourceName: testAccessPath},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -16,11 +16,14 @@ import (
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/database/users"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/errors"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/ffmpeg"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/gomedia"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/mediacache"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/utils"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/pkg/indexing"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/pkg/indexing/iteminfo"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/pkg/settings"
|
||||
"github.com/gtsteffaniak/go-logger/logger"
|
||||
"github.com/gtsteffaniak/go-media/pkg/media"
|
||||
)
|
||||
|
||||
// CheckPermissionsFunc allows tests to override CheckPermissions behavior
|
||||
@@ -50,7 +53,7 @@ func addMetadataToChildren(response *iteminfo.ExtendedFileInfo, opts utils.FileO
|
||||
logger.Debugf("failed to extract metadata for file: %s, error: %v", fileItem.Name, err)
|
||||
}
|
||||
} else {
|
||||
if err := extractVideoMetadata(context.Background(), fileItem, fullPath, sharedFFmpegService); err != nil {
|
||||
if err := extractVideoMetadata(context.Background(), fileItem, fullPath, opts.AlbumArt, sharedFFmpegService); err != nil {
|
||||
logger.Debugf("failed to extract video metadata for file: %s, error: %v", fileItem.Name, err)
|
||||
}
|
||||
}
|
||||
@@ -93,7 +96,7 @@ func processDirectoryMetadata(response *iteminfo.ExtendedFileInfo, idx *indexing
|
||||
// finalizeResponse handles final response adjustments (OnlyOffice ID, scope stripping).
|
||||
func finalizeResponse(response *iteminfo.ExtendedFileInfo, info *iteminfo.FileInfo, realPath string, user *users.User, userScope string) {
|
||||
// Add OnlyOffice ID if applicable
|
||||
if settings.Config.Integrations.OnlyOffice.Secret != "" && info.Type != "directory" && iteminfo.IsOnlyOffice(info.Name) {
|
||||
if settings.Config.Integrations.OnlyOffice.Secret != "" && !settings.Config.Integrations.OnlyOffice.IsCollabora() && info.Type != "directory" && iteminfo.IsOnlyOffice(info.Name) {
|
||||
response.OnlyOfficeId = generateOfficeId(realPath)
|
||||
}
|
||||
|
||||
@@ -378,9 +381,9 @@ func processContent(info *iteminfo.ExtendedFileInfo, idx *indexing.Index, opts u
|
||||
extItem := &iteminfo.ExtendedItemInfo{
|
||||
ItemInfo: info.ItemInfo,
|
||||
}
|
||||
err := extractVideoMetadata(context.Background(), extItem, info.RealPath, nil)
|
||||
err := extractVideoMetadata(context.Background(), extItem, info.RealPath, opts.AlbumArt, nil)
|
||||
if err != nil {
|
||||
logger.Debugf("failed to extract video metadata for file: "+info.RealPath, info.Name, err)
|
||||
logger.Debugf("failed to extract video metadata for file: %s (%s): %v", info.RealPath, info.Name, err)
|
||||
} else {
|
||||
info.Metadata = extItem.Metadata
|
||||
}
|
||||
@@ -390,10 +393,14 @@ func processContent(info *iteminfo.ExtendedFileInfo, idx *indexing.Index, opts u
|
||||
if exists {
|
||||
info.GetSubtitles(parentInfo)
|
||||
}
|
||||
if opts.ExtractEmbeddedSubtitles {
|
||||
subtitles := ffmpeg.DetectEmbeddedSubtitles(info.RealPath, info.ModTime)
|
||||
info.Subtitles = append(info.Subtitles, subtitles...)
|
||||
subtitles, ok := gomedia.EmbeddedSubtitles(info.RealPath, info.ModTime, func() ([]utils.SubtitleTrack, bool) {
|
||||
// Shadow run: bypass the shared cache so ffprobe is compared fresh.
|
||||
return ffmpeg.DetectEmbeddedSubtitlesContext(mediacache.WithoutCache(context.Background()), info.RealPath), true
|
||||
})
|
||||
if !ok {
|
||||
subtitles = ffmpeg.DetectEmbeddedSubtitles(info.RealPath, info.ModTime)
|
||||
}
|
||||
info.Subtitles = append(info.Subtitles, subtitles...)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -463,6 +470,17 @@ func extractAudioMetadata(ctx context.Context, item *iteminfo.ExtendedItemInfo,
|
||||
return fmt.Errorf("file with size %d MB exceeds metadata check limit: %d MB", fileInfo.Size()/1024/1024, maxSize)
|
||||
}
|
||||
|
||||
// go-media fast path: tags, lyrics availability, and artwork. Unsupported or
|
||||
// failed reads fall through to the existing dhowden/tag code below.
|
||||
if info, ok := gomedia.Audio(realPath, getArt, func() (gomedia.AudioInfo, bool) { return legacyAudioInfo(realPath, getArt) }); ok {
|
||||
item.Metadata = &iteminfo.MediaMetadata{HasLyrics: info.HasLyrics}
|
||||
applyMediaTags(item.Metadata, info, realPath)
|
||||
if getDuration {
|
||||
audioDuration(ctx, item, realPath, ffmpegService)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
m, err := tag.ReadFrom(file)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -486,15 +504,7 @@ func extractAudioMetadata(ctx context.Context, item *iteminfo.ExtendedItemInfo,
|
||||
// Extract duration ONLY if explicitly requested using the ffmpeg VideoService
|
||||
// This respects concurrency limits and gracefully handles missing ffmpeg
|
||||
if getDuration {
|
||||
service := ffmpegService
|
||||
if service == nil {
|
||||
service = ffmpeg.Get()
|
||||
}
|
||||
if service != nil {
|
||||
if duration, err := service.GetMediaDuration(ctx, realPath); err == nil {
|
||||
item.Metadata.Duration = int(duration)
|
||||
}
|
||||
}
|
||||
audioDuration(ctx, item, realPath, ffmpegService)
|
||||
}
|
||||
|
||||
if !getArt {
|
||||
@@ -514,6 +524,31 @@ func extractAudioMetadata(ctx context.Context, item *iteminfo.ExtendedItemInfo,
|
||||
return nil
|
||||
}
|
||||
|
||||
// audioDuration sets the duration on item.Metadata. go-media reads it from the
|
||||
// container header first, then ffmpeg is used.
|
||||
func audioDuration(ctx context.Context, item *iteminfo.ExtendedItemInfo, realPath string, ffmpegService *ffmpeg.FFmpegService) {
|
||||
service := ffmpegService
|
||||
if service == nil {
|
||||
service = ffmpeg.Get()
|
||||
}
|
||||
// The shadow run can outlive the request, so it uses a context that is not
|
||||
// cancelled with it. It bypasses the shared cache so ffmpeg is compared fresh.
|
||||
shadowCtx := mediacache.WithoutCache(context.WithoutCancel(ctx))
|
||||
legacy := func() (float64, bool) {
|
||||
d, err := service.GetMediaDuration(shadowCtx, realPath)
|
||||
return d, err == nil
|
||||
}
|
||||
if duration, ok := gomedia.Duration(realPath, legacy); ok {
|
||||
item.Metadata.Duration = int(duration)
|
||||
return
|
||||
}
|
||||
if service != nil {
|
||||
if duration, err := service.GetMediaDuration(ctx, realPath); err == nil {
|
||||
item.Metadata.Duration = int(duration)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var lyricsSidecarExts = []string{".elrc", ".lrc", ".srt", ".vtt"}
|
||||
|
||||
func lyricsSidecar(dir, nameWithoutExt, ext string) (path string, ok bool) {
|
||||
@@ -583,6 +618,11 @@ func hasLyricsSidecar(realPath string) bool {
|
||||
|
||||
// Returns raw lyrics from an audio file (from embedded tags or from sidecar files with the same name).
|
||||
func ExtractLyrics(realPath string) (string, string, error) {
|
||||
// go-media fast path: sidecar first, then embedded tags. Falls through to the
|
||||
// existing code below when unsupported or failed.
|
||||
if text, format, ok := gomedia.Lyrics(realPath, func() (gomedia.LyricsResult, bool) { return legacyLyrics(realPath) }); ok {
|
||||
return text, format, nil
|
||||
}
|
||||
if data, ext, ok := findLyricsSidecar(realPath); ok {
|
||||
return string(data), ext, nil
|
||||
}
|
||||
@@ -601,27 +641,101 @@ func ExtractLyrics(realPath string) (string, string, error) {
|
||||
return "", "", nil
|
||||
}
|
||||
|
||||
// legacyAudioInfo is the dhowden tag read used as the shadow-mode comparison
|
||||
// for gomedia.Audio. It returns the same fields go-media returns, so the two
|
||||
// can be compared. Cover bytes are read only when withArt is true.
|
||||
func legacyAudioInfo(realPath string, withArt bool) (gomedia.AudioInfo, bool) {
|
||||
f, err := os.Open(realPath)
|
||||
if err != nil {
|
||||
return gomedia.AudioInfo{}, false
|
||||
}
|
||||
defer f.Close()
|
||||
m, err := tag.ReadFrom(f)
|
||||
if err != nil {
|
||||
return gomedia.AudioInfo{}, false
|
||||
}
|
||||
track, _ := m.Track()
|
||||
info := gomedia.AudioInfo{
|
||||
Tags: media.Tags{
|
||||
Title: m.Title(),
|
||||
Artist: m.Artist(),
|
||||
Album: m.Album(),
|
||||
Year: m.Year(),
|
||||
Genre: m.Genre(),
|
||||
Track: track,
|
||||
},
|
||||
HasLyrics: strings.TrimSpace(m.Lyrics()) != "" || hasLyricsSidecar(realPath),
|
||||
}
|
||||
if withArt {
|
||||
if pic := m.Picture(); pic != nil {
|
||||
info.Artwork = pic.Data
|
||||
}
|
||||
}
|
||||
return info, true
|
||||
}
|
||||
|
||||
// legacyLyrics is the sidecar and dhowden lyrics read used as the shadow-mode
|
||||
// comparison for gomedia.Lyrics. Sidecar first, then embedded, as in go-media.
|
||||
func legacyLyrics(realPath string) (gomedia.LyricsResult, bool) {
|
||||
if data, ext, ok := findLyricsSidecar(realPath); ok {
|
||||
return gomedia.LyricsResult{Text: strings.TrimSpace(string(data)), Format: ext}, true
|
||||
}
|
||||
f, err := os.Open(realPath)
|
||||
if err != nil {
|
||||
return gomedia.LyricsResult{}, false
|
||||
}
|
||||
defer f.Close()
|
||||
m, err := tag.ReadFrom(f)
|
||||
if err != nil {
|
||||
return gomedia.LyricsResult{}, false
|
||||
}
|
||||
text := strings.TrimSpace(m.Lyrics())
|
||||
if text == "" {
|
||||
return gomedia.LyricsResult{}, false
|
||||
}
|
||||
return gomedia.LyricsResult{Text: text, Format: "embedded"}, true
|
||||
}
|
||||
|
||||
// extractVideoMetadata extracts duration and codec info from video files using ffprobe.
|
||||
// If ffmpegService is nil, a new service will be created (for backward compatibility)
|
||||
func extractVideoMetadata(ctx context.Context, item *iteminfo.ExtendedItemInfo, realPath string, ffmpegService *ffmpeg.FFmpegService) error {
|
||||
service := ffmpegService
|
||||
if service == nil {
|
||||
service = ffmpeg.Get()
|
||||
func extractVideoMetadata(ctx context.Context, item *iteminfo.ExtendedItemInfo, realPath string, getArt bool, ffmpegService *ffmpeg.FFmpegService) error {
|
||||
// go-media fast path. Works without ffmpeg installed.
|
||||
probeService := ffmpegService
|
||||
if probeService == nil {
|
||||
probeService = ffmpeg.Get()
|
||||
}
|
||||
if service == nil {
|
||||
return nil
|
||||
// The shadow run can outlive the request, so it uses a context that is not
|
||||
// cancelled with it. It bypasses the shared cache so ffprobe is compared fresh.
|
||||
shadowCtx := mediacache.WithoutCache(context.WithoutCancel(ctx))
|
||||
legacyProbe := func() (gomedia.ProbeResult, bool) {
|
||||
info, err := probeService.ProbeFile(shadowCtx, realPath)
|
||||
if err != nil || info == nil {
|
||||
return gomedia.ProbeResult{}, false
|
||||
}
|
||||
return *info, true
|
||||
}
|
||||
info, ok := gomedia.Probe(realPath, legacyProbe)
|
||||
if !ok {
|
||||
service := ffmpegService
|
||||
if service == nil {
|
||||
service = ffmpeg.Get()
|
||||
}
|
||||
if service == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
info, err := service.ProbeFile(ctx, realPath)
|
||||
if err != nil {
|
||||
duration, durErr := service.GetMediaDuration(ctx, realPath)
|
||||
if durErr != nil {
|
||||
return err
|
||||
probed, err := service.ProbeFile(ctx, realPath)
|
||||
if err != nil {
|
||||
duration, durErr := service.GetMediaDuration(ctx, realPath)
|
||||
if durErr != nil {
|
||||
return err
|
||||
}
|
||||
if duration > 0 {
|
||||
item.Metadata = &iteminfo.MediaMetadata{Duration: int(duration)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if duration > 0 {
|
||||
item.Metadata = &iteminfo.MediaMetadata{Duration: int(duration)}
|
||||
}
|
||||
return nil
|
||||
info = *probed
|
||||
}
|
||||
|
||||
meta := &iteminfo.MediaMetadata{}
|
||||
@@ -637,12 +751,33 @@ func extractVideoMetadata(ctx context.Context, item *iteminfo.ExtendedItemInfo,
|
||||
if info.FormatName != "" {
|
||||
meta.Container = info.FormatName
|
||||
}
|
||||
if ok {
|
||||
if tags, tagsOK := gomedia.VideoTags(realPath, getArt); tagsOK {
|
||||
applyMediaTags(meta, tags, realPath)
|
||||
}
|
||||
}
|
||||
if meta.Duration > 0 || meta.VideoCodec != "" || meta.AudioCodec != "" || meta.Container != "" {
|
||||
item.Metadata = meta
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// applyMediaTags copies go-media tags and embedded cover art into meta. Covers
|
||||
// over 8MB are skipped.
|
||||
func applyMediaTags(meta *iteminfo.MediaMetadata, info gomedia.AudioInfo, realPath string) {
|
||||
meta.Title = info.Tags.Title
|
||||
meta.Artist = info.Tags.Artist
|
||||
meta.Album = info.Tags.Album
|
||||
meta.Year = info.Tags.Year
|
||||
meta.Genre = info.Tags.Genre
|
||||
meta.Track = info.Tags.Track
|
||||
if n := len(info.Artwork); n > 0 && n <= 8*1024*1024 {
|
||||
meta.AlbumArt = info.Artwork
|
||||
} else if n > 8*1024*1024 {
|
||||
logger.Debugf("Skipping album art for %s: too large (%d bytes)", realPath, n)
|
||||
}
|
||||
}
|
||||
|
||||
// DeleteFiles deletes the file or directory at indexPath. boundIndexPath limits
|
||||
// symlink resolution to the caller's scope ("" or "/" = source root only). The
|
||||
// entry itself is removed: a symlink leaf is deleted, never followed, and an
|
||||
|
||||
@@ -55,6 +55,8 @@ const (
|
||||
var types = map[string]string{
|
||||
".3dm": "x-world/x-3dmf",
|
||||
".3dmf": "x-world/x-3dmf",
|
||||
".3g2": "video/3gpp2",
|
||||
".3gp": "video/3gpp",
|
||||
".7z": "application/x-7z-compressed",
|
||||
".a": "application/octet-stream",
|
||||
".aab": "application/x-authorware-bin",
|
||||
@@ -525,6 +527,7 @@ var types = map[string]string{
|
||||
".wmlc": "application/vnd.wap.wmlc",
|
||||
".wmls": "text/vnd.wap.wmlscript",
|
||||
".wmlsc": "application/vnd.wap.wmlscriptc",
|
||||
".wmv": "video/x-ms-wmv",
|
||||
".word": "application/msword",
|
||||
".wp5": "application/wordperfect",
|
||||
".wp6": "application/wordperfect",
|
||||
@@ -650,55 +653,55 @@ var types = map[string]string{
|
||||
".tmp": "text/tmp",
|
||||
".temp": "text/tmp",
|
||||
// the ones below are some from: https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
|
||||
".adp": "audio/adpcm",
|
||||
".mp4a": "audio/mp4",
|
||||
".mp2a": "audio/mpeg",
|
||||
".m3a": "audio/mpeg",
|
||||
".sil": "audio/silk",
|
||||
".uva": "audio/vnd.dece.audio",
|
||||
".uvva": "audio/vnd.dece.audio",
|
||||
".eol": "audio/vnd.digital-winds",
|
||||
".dra": "audio/vnd.dra",
|
||||
".dts": "audio/vnd.dts",
|
||||
".dtshd": "audio/vnd.dts.hd",
|
||||
".lvp": "audio/vnd.lucent.voice",
|
||||
".pya": "audio/vnd.ms-playready.media.pya",
|
||||
".rip": "audio/vnd.rip",
|
||||
".mka": "audio/x-matroska",
|
||||
".h261": "video/h261",
|
||||
".h263": "video/h263",
|
||||
".h264": "video/h264",
|
||||
".jpgv": "video/jpeg",
|
||||
".jpm": "video/jpm",
|
||||
".jpgm": "video/jpm",
|
||||
".mj2": "video/mj2",
|
||||
".mjp2": "video/mj2",
|
||||
".m2t": "video/mp2t",
|
||||
".m2ts": "video/mp2t",
|
||||
".mts": "video/mp2t",
|
||||
".mp4v": "video/mp4",
|
||||
".mpg4": "video/mp4",
|
||||
".uvh": "video/vnd.dece.hd",
|
||||
".uvvh": "video/vnd.dece.hd",
|
||||
".uvm": "video/vnd.dece.mobile",
|
||||
".uvvm": "video/vnd.dece.mobile",
|
||||
".uvp": "video/vnd.dece.pd",
|
||||
".uvvp": "video/vnd.dece.pd",
|
||||
".uvs": "video/vnd.dece.sd",
|
||||
".uvvs": "video/vnd.dece.sd",
|
||||
".uvv": "video/vnd.dece.video",
|
||||
".uvvv": "video/vnd.dece.video",
|
||||
".dvb": "video/vnd.dvb.file",
|
||||
".fvt": "video/vnd.fvt",
|
||||
".mxu": "video/vnd.mpegurl",
|
||||
".pyv": "video/vnd.ms-playready.media.pyv",
|
||||
".uvu": "video/vnd.uvvu.mp4",
|
||||
".uvvu": "video/vnd.uvvu.mp4",
|
||||
".f4v": "video/x-f4v",
|
||||
".mk3d": "video/x-matroska",
|
||||
".mks": "video/x-matroska",
|
||||
".vob": "video/x-ms-vob",
|
||||
".smv": "video/x-smv",
|
||||
".adp": "audio/adpcm",
|
||||
".mp4a": "audio/mp4",
|
||||
".mp2a": "audio/mpeg",
|
||||
".m3a": "audio/mpeg",
|
||||
".sil": "audio/silk",
|
||||
".uva": "audio/vnd.dece.audio",
|
||||
".uvva": "audio/vnd.dece.audio",
|
||||
".eol": "audio/vnd.digital-winds",
|
||||
".dra": "audio/vnd.dra",
|
||||
".dts": "audio/vnd.dts",
|
||||
".dtshd": "audio/vnd.dts.hd",
|
||||
".lvp": "audio/vnd.lucent.voice",
|
||||
".pya": "audio/vnd.ms-playready.media.pya",
|
||||
".rip": "audio/vnd.rip",
|
||||
".mka": "audio/x-matroska",
|
||||
".h261": "video/h261",
|
||||
".h263": "video/h263",
|
||||
".h264": "video/h264",
|
||||
".jpgv": "video/jpeg",
|
||||
".jpm": "video/jpm",
|
||||
".jpgm": "video/jpm",
|
||||
".mj2": "video/mj2",
|
||||
".mjp2": "video/mj2",
|
||||
".m2t": "video/mp2t",
|
||||
".m2ts": "video/mp2t",
|
||||
".mts": "video/mp2t",
|
||||
".mp4v": "video/mp4",
|
||||
".mpg4": "video/mp4",
|
||||
".uvh": "video/vnd.dece.hd",
|
||||
".uvvh": "video/vnd.dece.hd",
|
||||
".uvm": "video/vnd.dece.mobile",
|
||||
".uvvm": "video/vnd.dece.mobile",
|
||||
".uvp": "video/vnd.dece.pd",
|
||||
".uvvp": "video/vnd.dece.pd",
|
||||
".uvs": "video/vnd.dece.sd",
|
||||
".uvvs": "video/vnd.dece.sd",
|
||||
".uvv": "video/vnd.dece.video",
|
||||
".uvvv": "video/vnd.dece.video",
|
||||
".dvb": "video/vnd.dvb.file",
|
||||
".fvt": "video/vnd.fvt",
|
||||
".mxu": "video/vnd.mpegurl",
|
||||
".pyv": "video/vnd.ms-playready.media.pyv",
|
||||
".uvu": "video/vnd.uvvu.mp4",
|
||||
".uvvu": "video/vnd.uvvu.mp4",
|
||||
".f4v": "video/x-f4v",
|
||||
".mk3d": "video/x-matroska",
|
||||
".mks": "video/x-matroska",
|
||||
".vob": "video/x-ms-vob",
|
||||
".smv": "video/x-smv",
|
||||
}
|
||||
|
||||
//nolint:gochecknoinits
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package files
|
||||
|
||||
import (
|
||||
"mime"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Video containers that browsers cannot play must still be detected as video so
|
||||
// the preview routes to the transcode UI instead of showing "no preview".
|
||||
func TestVideoContainerExtensionsAreRegisteredAsVideo(t *testing.T) {
|
||||
tests := map[string]string{
|
||||
".wmv": "video/x-ms-wmv",
|
||||
".3gp": "video/3gpp",
|
||||
".3g2": "video/3gpp2",
|
||||
".mp4": "video/mp4",
|
||||
".avi": "video/x-msvideo",
|
||||
".mkv": "video/x-matroska",
|
||||
}
|
||||
for ext, want := range tests {
|
||||
got := mime.TypeByExtension(ext)
|
||||
if got != want {
|
||||
t.Errorf("mime.TypeByExtension(%q) = %q, want %q", ext, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package fileutils
|
||||
import (
|
||||
"io/fs"
|
||||
"net/http"
|
||||
|
||||
"github.com/gtsteffaniak/go-logger/logger"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -28,7 +30,17 @@ func InitAssetFS(embeddedAssets fs.FS, useEmbedded bool, devMode bool) {
|
||||
// Dev mode: serve frontend source assets (templates, fonts, icons)
|
||||
assetFs = dirFS{Dir: http.Dir("../frontend/public")}
|
||||
} else {
|
||||
assetFs = dirFS{Dir: http.Dir("internal/web/dist")}
|
||||
// Non-dev disk build (e.g. Docker): dist is shipped beside the binary. Preload it
|
||||
// into memory when possible; otherwise serve from disk.
|
||||
diskAssets := dirFS{Dir: http.Dir("internal/web/dist")}
|
||||
cached, err := loadMemFS(diskAssets)
|
||||
if err != nil {
|
||||
logger.Warningf("could not preload frontend assets into memory, serving from disk: %v", err)
|
||||
assetFs = diskAssets
|
||||
} else {
|
||||
logger.Debugf("preloaded %d frontend assets (%d bytes) into memory", cached.Len(), cached.Size())
|
||||
assetFs = cached
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
package fileutils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/fs"
|
||||
"time"
|
||||
)
|
||||
|
||||
// memFS is a read-only fs.FS that holds every file's contents in memory.
|
||||
// It is built once at startup from a disk-backed filesystem so that asset
|
||||
// requests never touch the disk.
|
||||
type memFS struct {
|
||||
files map[string]memFile
|
||||
}
|
||||
|
||||
type memFile struct {
|
||||
data []byte
|
||||
modTime time.Time
|
||||
}
|
||||
|
||||
// loadMemFS reads every regular file under src into memory.
|
||||
func loadMemFS(src fs.FS) (*memFS, error) {
|
||||
m := &memFS{files: make(map[string]memFile)}
|
||||
err := fs.WalkDir(src, ".", func(name string, d fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if d.IsDir() {
|
||||
return nil
|
||||
}
|
||||
data, err := fs.ReadFile(src, name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
info, err := d.Info()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
m.files[name] = memFile{data: data, modTime: info.ModTime()}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// Size returns the total number of bytes held in memory.
|
||||
func (m *memFS) Size() int {
|
||||
total := 0
|
||||
for _, f := range m.files {
|
||||
total += len(f.data)
|
||||
}
|
||||
return total
|
||||
}
|
||||
|
||||
// Len returns the number of files held in memory.
|
||||
func (m *memFS) Len() int {
|
||||
return len(m.files)
|
||||
}
|
||||
|
||||
// Open implements fs.FS. Only regular files are supported, which is all the
|
||||
// asset callers need (ReadFile, Stat and template parsing).
|
||||
func (m *memFS) Open(name string) (fs.File, error) {
|
||||
if !fs.ValidPath(name) {
|
||||
return nil, &fs.PathError{Op: "open", Path: name, Err: fs.ErrInvalid}
|
||||
}
|
||||
f, ok := m.files[name]
|
||||
if !ok {
|
||||
return nil, &fs.PathError{Op: "open", Path: name, Err: fs.ErrNotExist}
|
||||
}
|
||||
return &memOpenFile{
|
||||
Reader: bytes.NewReader(f.data),
|
||||
info: memFileInfo{
|
||||
name: baseName(name),
|
||||
size: int64(len(f.data)),
|
||||
modTime: f.modTime,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
type memOpenFile struct {
|
||||
*bytes.Reader
|
||||
info memFileInfo
|
||||
}
|
||||
|
||||
func (f *memOpenFile) Stat() (fs.FileInfo, error) { return f.info, nil }
|
||||
func (f *memOpenFile) Close() error { return nil }
|
||||
|
||||
type memFileInfo struct {
|
||||
name string
|
||||
size int64
|
||||
modTime time.Time
|
||||
}
|
||||
|
||||
func (i memFileInfo) Name() string { return i.name }
|
||||
func (i memFileInfo) Size() int64 { return i.size }
|
||||
func (i memFileInfo) Mode() fs.FileMode { return 0o444 }
|
||||
func (i memFileInfo) ModTime() time.Time { return i.modTime }
|
||||
func (i memFileInfo) IsDir() bool { return false }
|
||||
func (i memFileInfo) Sys() any { return nil }
|
||||
|
||||
func baseName(name string) string {
|
||||
for i := len(name) - 1; i >= 0; i-- {
|
||||
if name[i] == '/' {
|
||||
return name[i+1:]
|
||||
}
|
||||
}
|
||||
return name
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package fileutils
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLoadMemFSServesFromMemory(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
files := map[string]string{
|
||||
"index.html": "<html>index</html>",
|
||||
"assets/app.js.gz": "gzip-bytes",
|
||||
"fonts/icons.woff2": "font-bytes",
|
||||
}
|
||||
for name, content := range files {
|
||||
path := filepath.Join(dir, filepath.FromSlash(name))
|
||||
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(path, []byte(content), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
m, err := loadMemFS(dirFS{Dir: http.Dir(dir)})
|
||||
if err != nil {
|
||||
t.Fatalf("loadMemFS: %v", err)
|
||||
}
|
||||
if m.Len() != len(files) {
|
||||
t.Fatalf("loaded %d files, want %d", m.Len(), len(files))
|
||||
}
|
||||
|
||||
// Remove everything from disk: the cache must still serve every file.
|
||||
if removeErr := os.RemoveAll(dir); removeErr != nil {
|
||||
t.Fatal(removeErr)
|
||||
}
|
||||
for name, want := range files {
|
||||
got, readErr := fs.ReadFile(m, name)
|
||||
if readErr != nil {
|
||||
t.Fatalf("ReadFile(%s) after disk removal: %v", name, readErr)
|
||||
}
|
||||
if string(got) != want {
|
||||
t.Errorf("ReadFile(%s) = %q, want %q", name, got, want)
|
||||
}
|
||||
info, statErr := fs.Stat(m, name)
|
||||
if statErr != nil {
|
||||
t.Fatalf("Stat(%s): %v", name, statErr)
|
||||
}
|
||||
if info.IsDir() || info.Size() != int64(len(want)) || info.Name() != filepath.Base(name) {
|
||||
t.Errorf("Stat(%s) = %+v, unexpected", name, info)
|
||||
}
|
||||
}
|
||||
|
||||
// Template-style glob on a plain name must resolve via Stat.
|
||||
matches, globErr := fs.Glob(m, "index.html")
|
||||
if globErr != nil || len(matches) != 1 {
|
||||
t.Fatalf("Glob(index.html) = %v, %v", matches, globErr)
|
||||
}
|
||||
|
||||
if _, readErr := fs.ReadFile(m, "missing.css"); readErr == nil {
|
||||
t.Error("ReadFile(missing.css) should fail")
|
||||
}
|
||||
if _, readErr := fs.ReadFile(m, "../escape"); readErr == nil {
|
||||
t.Error("invalid path should be rejected")
|
||||
}
|
||||
}
|
||||
@@ -205,8 +205,8 @@ func collectPayload(versionLabel string) (snapshotPayload, error) {
|
||||
Integrations: integrationsPayload{
|
||||
OnlyOfficeConfigured: strings.TrimSpace(settings.Config.Integrations.OnlyOffice.Url) != "",
|
||||
OnlyOfficeViewOnly: settings.Config.Integrations.OnlyOffice.ViewOnly,
|
||||
MediaEnabled: settings.MediaEnabled(),
|
||||
HardwareAcceleration: settings.Config.Integrations.Media.HardwareAcceleration,
|
||||
MediaEnabled: settings.FFmpegEnabled(),
|
||||
HardwareAcceleration: settings.HardwareAccelerationEnabled(),
|
||||
},
|
||||
Features: featuresPayload{
|
||||
DisablePreviews: settings.Config.Server.DisablePreviews,
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/activity"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/adapters/fs/files"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/auth"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/state"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/transcoding"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/pkg/indexing"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/pkg/settings"
|
||||
)
|
||||
|
||||
// App holds wired dependencies for the running process.
|
||||
@@ -17,6 +22,11 @@ type App struct {
|
||||
|
||||
// WireServices connects domain packages to the state store after Open.
|
||||
func WireServices(store *state.Store) (*App, error) {
|
||||
return WireServicesWithContext(context.Background(), store)
|
||||
}
|
||||
|
||||
// WireServicesWithContext wires services using ctx for background workers.
|
||||
func WireServicesWithContext(ctx context.Context, store *state.Store) (*App, error) {
|
||||
filesSvc := files.New(store, store, store)
|
||||
authSvc := auth.New(store)
|
||||
files.SetDefault(filesSvc)
|
||||
@@ -26,6 +36,24 @@ func WireServices(store *state.Store) (*App, error) {
|
||||
if err := auth.InitWebAuthn(store); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Always create the manager: the engine re-checks ffmpeg availability per
|
||||
// request, so a runtime admin settings change takes effect without restart.
|
||||
storeDir, err := transcoding.NewStore(settings.TranscodeCacheDir())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Delivery URLs stay root-relative so a subpath deployment or alternate
|
||||
// hostname still resolves and the session cookie is sent.
|
||||
transcodeMgr, err := transcoding.NewManager(ctx, transcoding.NewMediaEngine(), storeDir,
|
||||
strings.TrimRight(settings.Config.Http.BaseURL, "/"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Exported so the web layer (and shutdown) can reach it without threading
|
||||
// it through StartHttp's Deps.
|
||||
transcoding.SetDefault(transcodeMgr)
|
||||
|
||||
return &App{
|
||||
Store: store,
|
||||
Files: filesSvc,
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"fmt"
|
||||
"math"
|
||||
"net/http"
|
||||
"sort"
|
||||
"net/url"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -214,24 +215,29 @@ func TestJSONAuth_NoTimingAttack(t *testing.T) {
|
||||
{"fakeadmin", false},
|
||||
}
|
||||
|
||||
// Number of samples per test case for statistical analysis
|
||||
samplesPerCase := 5
|
||||
const warmupIterations = 10
|
||||
const samplesPerCase = 40
|
||||
|
||||
// Collect timing measurements
|
||||
measurements := make(map[string][]time.Duration)
|
||||
for _, tc := range testCases {
|
||||
measurements[tc.username] = make([]time.Duration, 0, samplesPerCase)
|
||||
measurements[tc.username] = make([]time.Duration, 0, warmupIterations+samplesPerCase)
|
||||
}
|
||||
|
||||
// Run multiple iterations to gather statistical data
|
||||
for i := 0; i < samplesPerCase; i++ {
|
||||
// Randomize order to avoid cache effects
|
||||
runRound := func() {
|
||||
for _, tc := range testCases {
|
||||
elapsed := measureAuthTime(t, auther, tc.username, "wrongpassword123")
|
||||
measurements[tc.username] = append(measurements[tc.username], elapsed)
|
||||
}
|
||||
}
|
||||
|
||||
for i := 0; i < warmupIterations; i++ {
|
||||
runRound()
|
||||
}
|
||||
for i := 0; i < samplesPerCase; i++ {
|
||||
runRound()
|
||||
}
|
||||
|
||||
// Calculate statistics for each test case
|
||||
type stats struct {
|
||||
mean time.Duration
|
||||
@@ -240,7 +246,28 @@ func TestJSONAuth_NoTimingAttack(t *testing.T) {
|
||||
max time.Duration
|
||||
}
|
||||
|
||||
measurementSamples := func(durations []time.Duration) []time.Duration {
|
||||
if len(durations) <= warmupIterations {
|
||||
return durations
|
||||
}
|
||||
return durations[warmupIterations:]
|
||||
}
|
||||
|
||||
medianDuration := func(durations []time.Duration) time.Duration {
|
||||
if len(durations) == 0 {
|
||||
return 0
|
||||
}
|
||||
sorted := append([]time.Duration(nil), durations...)
|
||||
sort.Slice(sorted, func(i, j int) bool { return sorted[i] < sorted[j] })
|
||||
mid := len(sorted) / 2
|
||||
if len(sorted)%2 == 0 {
|
||||
return (sorted[mid-1] + sorted[mid]) / 2
|
||||
}
|
||||
return sorted[mid]
|
||||
}
|
||||
|
||||
calculateStats := func(durations []time.Duration) stats {
|
||||
durations = measurementSamples(durations)
|
||||
if len(durations) == 0 {
|
||||
return stats{}
|
||||
}
|
||||
@@ -297,31 +324,36 @@ func TestJSONAuth_NoTimingAttack(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate overall statistics for valid vs invalid users
|
||||
var validMeanSum, invalidMeanSum time.Duration
|
||||
for _, s := range validUserStats {
|
||||
validMeanSum += s.mean
|
||||
}
|
||||
for _, s := range invalidUserStats {
|
||||
invalidMeanSum += s.mean
|
||||
// Pool per-username medians so one username is not overweighted vs others.
|
||||
validMedians := make([]time.Duration, 0, len(validUserStats))
|
||||
invalidMedians := make([]time.Duration, 0, len(invalidUserStats))
|
||||
for _, tc := range testCases {
|
||||
samples := measurementSamples(measurements[tc.username])
|
||||
med := medianDuration(samples)
|
||||
if tc.isValid {
|
||||
validMedians = append(validMedians, med)
|
||||
} else {
|
||||
invalidMedians = append(invalidMedians, med)
|
||||
}
|
||||
}
|
||||
|
||||
validAvgMean := validMeanSum / time.Duration(len(validUserStats))
|
||||
invalidAvgMean := invalidMeanSum / time.Duration(len(invalidUserStats))
|
||||
validPooledMedian := medianDuration(validMedians)
|
||||
invalidPooledMedian := medianDuration(invalidMedians)
|
||||
|
||||
t.Logf("\n=== Summary ===")
|
||||
t.Logf("Valid users average: %.4fms", float64(validAvgMean.Microseconds())/1000.0)
|
||||
t.Logf("Invalid users average: %.4fms", float64(invalidAvgMean.Microseconds())/1000.0)
|
||||
t.Logf("Valid users pooled median: %.4fms", float64(validPooledMedian.Microseconds())/1000.0)
|
||||
t.Logf("Invalid users pooled median: %.4fms", float64(invalidPooledMedian.Microseconds())/1000.0)
|
||||
|
||||
// Calculate the percentage difference
|
||||
diff := float64(validAvgMean - invalidAvgMean)
|
||||
percentDiff := math.Abs(diff) / float64(validAvgMean) * 100.0
|
||||
diff := float64(validPooledMedian - invalidPooledMedian)
|
||||
denominator := float64(validPooledMedian)
|
||||
if denominator == 0 {
|
||||
denominator = float64(invalidPooledMedian)
|
||||
}
|
||||
percentDiff := math.Abs(diff) / denominator * 100.0
|
||||
t.Logf("Difference: %.4fms (%.2f%%)", diff/1e6, percentDiff)
|
||||
|
||||
// Assert: The timing difference should be less than 20%
|
||||
// Bcrypt's constant-time comparison should make both cases take similar time
|
||||
// We allow 20% threshold to account for system noise and variability
|
||||
threshold := 20.0 // percent
|
||||
// Medians of many bcrypt(check) samples should track; allow slack for scheduler noise.
|
||||
threshold := 25.0 // percent
|
||||
if percentDiff > threshold {
|
||||
t.Errorf("TIMING ATTACK VULNERABILITY DETECTED: Valid vs invalid user timing differs by %.2f%% (threshold: %.2f%%)",
|
||||
percentDiff, threshold)
|
||||
@@ -331,25 +363,26 @@ func TestJSONAuth_NoTimingAttack(t *testing.T) {
|
||||
percentDiff, threshold)
|
||||
}
|
||||
|
||||
// Additional check: Ensure no individual case is an obvious outlier
|
||||
// Check if any single user's timing is significantly faster than bcrypt operations
|
||||
allStats := append(validUserStats, invalidUserStats...)
|
||||
var allMeansSum time.Duration
|
||||
for _, s := range allStats {
|
||||
allMeansSum += s.mean
|
||||
// Fast path bypass would show up as one group finishing far quicker than bcrypt work.
|
||||
const minExpected = 400 * time.Microsecond // bcrypt cost 4 is ~1ms; allow wide slack
|
||||
if validPooledMedian < minExpected || invalidPooledMedian < minExpected {
|
||||
t.Errorf("suspiciously fast auth path: valid median=%v invalid median=%v (expected bcrypt comparison)",
|
||||
validPooledMedian, invalidPooledMedian)
|
||||
}
|
||||
overallMean := allMeansSum / time.Duration(len(allStats))
|
||||
|
||||
allMedians := append(append([]time.Duration(nil), validMedians...), invalidMedians...)
|
||||
overallMedian := medianDuration(allMedians)
|
||||
|
||||
for _, tc := range testCases {
|
||||
s := calculateStats(measurements[tc.username])
|
||||
deviation := math.Abs(float64(s.mean-overallMean)) / float64(overallMean) * 100.0
|
||||
samples := measurementSamples(measurements[tc.username])
|
||||
userMed := medianDuration(samples)
|
||||
deviation := math.Abs(float64(userMed-overallMedian)) / float64(overallMedian) * 100.0
|
||||
|
||||
// If any user is more than 30% faster/slower than average, it's suspicious
|
||||
if deviation > 30.0 {
|
||||
t.Errorf("OUTLIER DETECTED: %s deviates by %.2f%% from overall mean (%.4fms vs %.4fms)",
|
||||
if deviation > 40.0 {
|
||||
t.Errorf("OUTLIER DETECTED: %s median deviates by %.2f%% from pooled median (%.4fms vs %.4fms)",
|
||||
tc.username, deviation,
|
||||
float64(s.mean.Microseconds())/1000.0,
|
||||
float64(overallMean.Microseconds())/1000.0)
|
||||
float64(userMed.Microseconds())/1000.0,
|
||||
float64(overallMedian.Microseconds())/1000.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,311 @@
|
||||
// Package shadowregress stores significant go-media vs ffmpeg regressions found
|
||||
// by dev-mode shadow runs, so admins can review them in the settings UI.
|
||||
//
|
||||
// The database holds one row per file. A file is identified by a hash of its
|
||||
// path, so repeated regressions for the same file update that row (latest
|
||||
// detail, plus an occurrence count) instead of adding entries.
|
||||
//
|
||||
// The database is a separate SQLite file in the cache directory's sql/ folder,
|
||||
// created the same way as the index database. It is opened lazily, so nothing
|
||||
// is created until the first regression is recorded or the viewer is opened.
|
||||
package shadowregress
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
dbsql "github.com/gtsteffaniak/filebrowser/backend/internal/database/sql"
|
||||
)
|
||||
|
||||
// MaxEntries is the most files kept. The least recently seen rows are pruned on insert.
|
||||
const MaxEntries = 1000
|
||||
|
||||
const schema = `
|
||||
CREATE TABLE IF NOT EXISTS shadow_regressions (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
file_key TEXT NOT NULL UNIQUE,
|
||||
first_seen INTEGER NOT NULL,
|
||||
created_at INTEGER NOT NULL,
|
||||
operation TEXT NOT NULL,
|
||||
label TEXT NOT NULL,
|
||||
detail TEXT NOT NULL,
|
||||
format TEXT NOT NULL,
|
||||
size_bytes INTEGER NOT NULL,
|
||||
codecs TEXT NOT NULL DEFAULT '',
|
||||
occurrences INTEGER NOT NULL DEFAULT 1
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_shadow_regressions_created ON shadow_regressions(created_at, id);`
|
||||
|
||||
// incompatibleSchema holds files go-media does not support that ffmpeg handled.
|
||||
// Unlike shadow_regressions, it stores the file path so the list can name the files.
|
||||
const incompatibleSchema = `
|
||||
CREATE TABLE IF NOT EXISTS shadow_incompatible (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
file_key TEXT NOT NULL UNIQUE,
|
||||
first_seen INTEGER NOT NULL,
|
||||
created_at INTEGER NOT NULL,
|
||||
operation TEXT NOT NULL,
|
||||
path TEXT NOT NULL,
|
||||
format TEXT NOT NULL,
|
||||
size_bytes INTEGER NOT NULL,
|
||||
occurrences INTEGER NOT NULL DEFAULT 1
|
||||
);`
|
||||
|
||||
// IncompatibleEntry is one file go-media does not support that ffmpeg handled.
|
||||
type IncompatibleEntry struct {
|
||||
FileKey string `json:"-"`
|
||||
FirstSeen time.Time `json:"firstSeen"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
Occurrences int64 `json:"occurrences"`
|
||||
Operation string `json:"operation"`
|
||||
Path string `json:"path"`
|
||||
Format string `json:"format"`
|
||||
SizeBytes int64 `json:"sizeBytes"`
|
||||
}
|
||||
|
||||
// Entry is one file's most recent regression. It contains no file name or path.
|
||||
type Entry struct {
|
||||
// FileKey identifies the file (a hash of its path). It is required and not
|
||||
// returned to the UI.
|
||||
FileKey string `json:"-"`
|
||||
FirstSeen time.Time `json:"firstSeen"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
Occurrences int64 `json:"occurrences"`
|
||||
Operation string `json:"operation"`
|
||||
Label string `json:"label"`
|
||||
Detail string `json:"detail"`
|
||||
Format string `json:"format"`
|
||||
SizeBytes int64 `json:"sizeBytes"`
|
||||
Codecs string `json:"codecs,omitempty"`
|
||||
}
|
||||
|
||||
// Store is safe for concurrent use. The zero value is ready to use.
|
||||
type Store struct {
|
||||
once sync.Once
|
||||
db *dbsql.TempDB
|
||||
err error
|
||||
// writeMu serializes Record so upserts and pruning do not interleave.
|
||||
writeMu sync.Mutex
|
||||
}
|
||||
|
||||
func (s *Store) open() (*dbsql.TempDB, error) {
|
||||
s.once.Do(func() {
|
||||
db, err := dbsql.NewTempDB("shadow_regressions", &dbsql.TempDBConfig{
|
||||
PersistentFile: "shadow_regressions.db",
|
||||
})
|
||||
if err != nil {
|
||||
s.err = fmt.Errorf("open shadow regressions database: %w", err)
|
||||
return
|
||||
}
|
||||
if err := migrate(db); err != nil {
|
||||
db.Close()
|
||||
s.err = err
|
||||
return
|
||||
}
|
||||
s.db = db
|
||||
})
|
||||
return s.db, s.err
|
||||
}
|
||||
|
||||
// migrate rebuilds the table when it has the earlier layout (one row per regression,
|
||||
// no file_key). The table only holds dev-mode diagnostics, so the old rows are dropped.
|
||||
func migrate(db *dbsql.TempDB) error {
|
||||
var hasFileKey int
|
||||
if err := db.DB().QueryRow(
|
||||
`SELECT COUNT(*) FROM pragma_table_info('shadow_regressions') WHERE name = 'file_key'`,
|
||||
).Scan(&hasFileKey); err != nil {
|
||||
return fmt.Errorf("inspect shadow regressions table: %w", err)
|
||||
}
|
||||
if hasFileKey == 0 {
|
||||
if _, err := db.Exec(`DROP TABLE IF EXISTS shadow_regressions`); err != nil {
|
||||
return fmt.Errorf("drop old shadow regressions table: %w", err)
|
||||
}
|
||||
}
|
||||
if _, err := db.Exec(schema); err != nil {
|
||||
return fmt.Errorf("create shadow regressions table: %w", err)
|
||||
}
|
||||
if _, err := db.Exec(incompatibleSchema); err != nil {
|
||||
return fmt.Errorf("create shadow incompatible table: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// RecordIncompatible stores a file go-media does not support that ffmpeg handled.
|
||||
// A file that is already listed is updated in place and its count goes up by one.
|
||||
func (s *Store) RecordIncompatible(e IncompatibleEntry) error {
|
||||
if e.FileKey == "" {
|
||||
return errors.New("incompatible file has no file key")
|
||||
}
|
||||
s.writeMu.Lock()
|
||||
defer s.writeMu.Unlock()
|
||||
|
||||
db, err := s.open()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tx, err := db.DB().Begin()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Rollback after a successful Commit returns sql.ErrTxDone, which is safe to ignore.
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
|
||||
if _, err := tx.Exec(
|
||||
`INSERT INTO shadow_incompatible
|
||||
(file_key, first_seen, created_at, operation, path, format, size_bytes, occurrences)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, 1)
|
||||
ON CONFLICT(file_key) DO UPDATE SET
|
||||
created_at = excluded.created_at,
|
||||
operation = excluded.operation,
|
||||
path = excluded.path,
|
||||
format = excluded.format,
|
||||
size_bytes = excluded.size_bytes,
|
||||
occurrences = occurrences + 1`,
|
||||
e.FileKey, e.CreatedAt.UnixMilli(), e.CreatedAt.UnixMilli(), e.Operation, e.Path, e.Format, e.SizeBytes,
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := tx.Exec(
|
||||
`DELETE FROM shadow_incompatible WHERE id NOT IN (
|
||||
SELECT id FROM shadow_incompatible ORDER BY created_at DESC, id DESC LIMIT ?)`,
|
||||
MaxEntries,
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.Commit()
|
||||
}
|
||||
|
||||
// ListIncompatible returns one entry per file, most recently seen first.
|
||||
func (s *Store) ListIncompatible() ([]IncompatibleEntry, error) {
|
||||
db, err := s.open()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rows, err := db.Query(
|
||||
`SELECT first_seen, created_at, occurrences, operation, path, format, size_bytes
|
||||
FROM shadow_incompatible ORDER BY created_at DESC, id DESC`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
entries := []IncompatibleEntry{}
|
||||
for rows.Next() {
|
||||
var (
|
||||
firstMs, createdMs int64
|
||||
e IncompatibleEntry
|
||||
)
|
||||
if err := rows.Scan(&firstMs, &createdMs, &e.Occurrences, &e.Operation, &e.Path, &e.Format, &e.SizeBytes); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
e.FirstSeen = time.UnixMilli(firstMs).UTC()
|
||||
e.CreatedAt = time.UnixMilli(createdMs).UTC()
|
||||
entries = append(entries, e)
|
||||
}
|
||||
return entries, rows.Err()
|
||||
}
|
||||
|
||||
// Record stores the latest regression for e's file. A file that already has a
|
||||
// row is updated in place and its occurrence count goes up by one.
|
||||
func (s *Store) Record(e Entry) error {
|
||||
if e.FileKey == "" {
|
||||
return errors.New("shadow regression has no file key")
|
||||
}
|
||||
s.writeMu.Lock()
|
||||
defer s.writeMu.Unlock()
|
||||
|
||||
db, err := s.open()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Use the raw *sql.DB rather than TempDB.BeginTransaction: that method takes
|
||||
// TempDB's internal mutex and expects the caller to release it, which this
|
||||
// package cannot do, so every later query would deadlock.
|
||||
tx, err := db.DB().Begin()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Rollback after a successful Commit returns sql.ErrTxDone, which is safe to ignore.
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
|
||||
if _, err := tx.Exec(
|
||||
`INSERT INTO shadow_regressions
|
||||
(file_key, first_seen, created_at, operation, label, detail, format, size_bytes, codecs, occurrences)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 1)
|
||||
ON CONFLICT(file_key) DO UPDATE SET
|
||||
created_at = excluded.created_at,
|
||||
operation = excluded.operation,
|
||||
label = excluded.label,
|
||||
detail = excluded.detail,
|
||||
format = excluded.format,
|
||||
size_bytes = excluded.size_bytes,
|
||||
codecs = excluded.codecs,
|
||||
occurrences = occurrences + 1`,
|
||||
e.FileKey, e.CreatedAt.UnixMilli(), e.CreatedAt.UnixMilli(), e.Operation, e.Label, e.Detail,
|
||||
e.Format, e.SizeBytes, e.Codecs,
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
// Prune by last-seen time, so a file that keeps regressing is not dropped
|
||||
// just because its row was created long ago. Only the rows over the limit
|
||||
// are removed, oldest first, so the index on created_at does the work and
|
||||
// a normal insert deletes nothing.
|
||||
if _, err := tx.Exec(
|
||||
`DELETE FROM shadow_regressions WHERE id IN (
|
||||
SELECT id FROM shadow_regressions ORDER BY created_at ASC, id ASC
|
||||
LIMIT MAX(0, (SELECT COUNT(*) FROM shadow_regressions) - ?))`,
|
||||
MaxEntries,
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.Commit()
|
||||
}
|
||||
|
||||
// List returns one entry per file, most recently seen first.
|
||||
func (s *Store) List() ([]Entry, error) {
|
||||
db, err := s.open()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rows, err := db.Query(
|
||||
`SELECT first_seen, created_at, occurrences, operation, label, detail, format, size_bytes, codecs
|
||||
FROM shadow_regressions ORDER BY created_at DESC, id DESC`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
entries := []Entry{}
|
||||
for rows.Next() {
|
||||
var (
|
||||
firstMs, createdMs int64
|
||||
e Entry
|
||||
)
|
||||
if err := rows.Scan(&firstMs, &createdMs, &e.Occurrences, &e.Operation, &e.Label, &e.Detail,
|
||||
&e.Format, &e.SizeBytes, &e.Codecs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
e.FirstSeen = time.UnixMilli(firstMs).UTC()
|
||||
e.CreatedAt = time.UnixMilli(createdMs).UTC()
|
||||
entries = append(entries, e)
|
||||
}
|
||||
return entries, rows.Err()
|
||||
}
|
||||
|
||||
// Clear removes every stored regression and every incompatible file.
|
||||
func (s *Store) Clear() error {
|
||||
s.writeMu.Lock()
|
||||
defer s.writeMu.Unlock()
|
||||
|
||||
db, err := s.open()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err = db.Exec(`DELETE FROM shadow_regressions`); err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = db.Exec(`DELETE FROM shadow_incompatible`)
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
package shadowregress
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/adapters/fs/fileutils"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/pkg/settings"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// useCacheDir points the cache directory at a temp dir for one test, so the
|
||||
// database is created there the same way the index database is.
|
||||
func useCacheDir(t *testing.T) string {
|
||||
t.Helper()
|
||||
if fileutils.PermDir == 0 {
|
||||
fileutils.SetFsPermissions(0o644, 0o755)
|
||||
}
|
||||
dir := t.TempDir()
|
||||
prev := settings.Config.Server.CacheDir
|
||||
settings.Config.Server.CacheDir = dir
|
||||
t.Cleanup(func() { settings.Config.Server.CacheDir = prev })
|
||||
return dir
|
||||
}
|
||||
|
||||
func TestStoreRecordAndListNewestFirst(t *testing.T) {
|
||||
dir := useCacheDir(t)
|
||||
s := &Store{}
|
||||
|
||||
require.NoError(t, s.Record(Entry{FileKey: "a", CreatedAt: time.Now(), Operation: "duration", Label: "error", Detail: "first", Format: "mp4", SizeBytes: 10}))
|
||||
require.NoError(t, s.Record(Entry{FileKey: "b", CreatedAt: time.Now(), Operation: "probe", Label: "timeRegression", Detail: "second", Format: "mkv", SizeBytes: 20, Codecs: "video=h264 audio=aac"}))
|
||||
|
||||
entries, err := s.List()
|
||||
require.NoError(t, err)
|
||||
require.Len(t, entries, 2)
|
||||
require.Equal(t, "second", entries[0].Detail)
|
||||
require.Equal(t, "video=h264 audio=aac", entries[0].Codecs)
|
||||
require.Equal(t, int64(1), entries[0].Occurrences)
|
||||
require.Equal(t, "first", entries[1].Detail)
|
||||
|
||||
// The database lives in the cache directory's sql/ folder, like the index database.
|
||||
_, err = os.Stat(filepath.Join(dir, "sql", "shadow_regressions.db"))
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestStoreListEmptyIsEmptySlice(t *testing.T) {
|
||||
useCacheDir(t)
|
||||
s := &Store{}
|
||||
|
||||
entries, err := s.List()
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, entries)
|
||||
require.Empty(t, entries)
|
||||
}
|
||||
|
||||
func TestStorePrunesToMaxEntries(t *testing.T) {
|
||||
useCacheDir(t)
|
||||
s := &Store{}
|
||||
|
||||
for i := 0; i < MaxEntries+5; i++ {
|
||||
require.NoError(t, s.Record(Entry{FileKey: fmt.Sprint("file-", i), CreatedAt: time.Now(), Operation: "duration", Label: "error", Detail: fmt.Sprint(i), Format: "mp4"}))
|
||||
}
|
||||
|
||||
entries, err := s.List()
|
||||
require.NoError(t, err)
|
||||
require.Len(t, entries, MaxEntries)
|
||||
require.Equal(t, fmt.Sprint(MaxEntries+4), entries[0].Detail, "newest entry is kept")
|
||||
}
|
||||
|
||||
// One file, many regressions: one row. The row shows the latest detail, the
|
||||
// first time the file was seen, and how many times it regressed.
|
||||
func TestStoreOneRowPerFile(t *testing.T) {
|
||||
useCacheDir(t)
|
||||
s := &Store{}
|
||||
first := time.Now().Add(-time.Hour)
|
||||
|
||||
for i := 0; i < 5; i++ {
|
||||
require.NoError(t, s.Record(Entry{
|
||||
FileKey: "same-file",
|
||||
CreatedAt: first.Add(time.Duration(i) * time.Minute),
|
||||
Operation: "heic jpeg", Label: "timeRegression", Detail: fmt.Sprint("run ", i),
|
||||
Format: "heic", SizeBytes: 1777539,
|
||||
}))
|
||||
}
|
||||
// A different file is a different row, even with identical metadata.
|
||||
require.NoError(t, s.Record(Entry{FileKey: "other-file", CreatedAt: first, Operation: "heic jpeg", Label: "timeRegression", Detail: "other", Format: "heic", SizeBytes: 1777539}))
|
||||
|
||||
entries, err := s.List()
|
||||
require.NoError(t, err)
|
||||
require.Len(t, entries, 2)
|
||||
|
||||
// The file with the latest sighting is first.
|
||||
require.Equal(t, "run 4", entries[0].Detail)
|
||||
require.Equal(t, int64(5), entries[0].Occurrences)
|
||||
require.Equal(t, first.UnixMilli(), entries[0].FirstSeen.UnixMilli(), "first seen is kept")
|
||||
require.Equal(t, first.Add(4*time.Minute).UnixMilli(), entries[0].CreatedAt.UnixMilli())
|
||||
|
||||
require.Equal(t, "other", entries[1].Detail)
|
||||
require.Equal(t, int64(1), entries[1].Occurrences)
|
||||
}
|
||||
|
||||
// A file that keeps regressing stays in the list, even after many other files
|
||||
// were recorded after its first row.
|
||||
func TestStorePruneKeepsRecentlySeenFile(t *testing.T) {
|
||||
useCacheDir(t)
|
||||
s := &Store{}
|
||||
base := time.Now().Add(-time.Hour)
|
||||
|
||||
// The busy file is recorded first, so it is the oldest row at the start.
|
||||
require.NoError(t, s.Record(Entry{FileKey: "busy", CreatedAt: base, Operation: "duration", Label: "error", Detail: "busy", Format: "mp4"}))
|
||||
for i := 0; i < MaxEntries-1; i++ {
|
||||
require.NoError(t, s.Record(Entry{FileKey: fmt.Sprint("other-", i), CreatedAt: base.Add(time.Duration(i+1) * time.Second), Operation: "duration", Label: "error", Detail: "x", Format: "mp4"}))
|
||||
}
|
||||
// The busy file regresses again. It updates its row and becomes the most recently seen.
|
||||
require.NoError(t, s.Record(Entry{FileKey: "busy", CreatedAt: base.Add(time.Hour), Operation: "duration", Label: "error", Detail: "busy again", Format: "mp4"}))
|
||||
// One more file takes the table over the limit, so one row is pruned.
|
||||
require.NoError(t, s.Record(Entry{FileKey: "last", CreatedAt: base.Add(2 * time.Hour), Operation: "duration", Label: "error", Detail: "last", Format: "mp4"}))
|
||||
|
||||
entries, err := s.List()
|
||||
require.NoError(t, err)
|
||||
require.Len(t, entries, MaxEntries)
|
||||
require.Equal(t, "last", entries[0].Detail)
|
||||
require.Equal(t, "busy again", entries[1].Detail, "busy file survives the prune")
|
||||
require.Equal(t, int64(2), entries[1].Occurrences)
|
||||
}
|
||||
|
||||
func TestStoreRejectsEntryWithoutFileKey(t *testing.T) {
|
||||
useCacheDir(t)
|
||||
s := &Store{}
|
||||
|
||||
require.Error(t, s.Record(Entry{CreatedAt: time.Now(), Operation: "duration", Label: "error", Detail: "x", Format: "mp4"}))
|
||||
entries, err := s.List()
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, entries)
|
||||
}
|
||||
|
||||
func TestStoreClearRemovesAll(t *testing.T) {
|
||||
useCacheDir(t)
|
||||
s := &Store{}
|
||||
|
||||
require.NoError(t, s.Record(Entry{FileKey: "x", CreatedAt: time.Now(), Operation: "duration", Label: "error", Detail: "x", Format: "mp4"}))
|
||||
require.NoError(t, s.Clear())
|
||||
|
||||
entries, err := s.List()
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, entries)
|
||||
}
|
||||
|
||||
func TestStoreIncompatibleOneRowPerFileAndClear(t *testing.T) {
|
||||
useCacheDir(t)
|
||||
s := &Store{}
|
||||
now := time.Now()
|
||||
|
||||
for i := 0; i < 3; i++ {
|
||||
require.NoError(t, s.RecordIncompatible(IncompatibleEntry{
|
||||
FileKey: "wmv-file", CreatedAt: now.Add(time.Duration(i) * time.Second),
|
||||
Operation: "video thumbnail", Path: "/lib/clip.wmv", Format: "wmv", SizeBytes: 50,
|
||||
}))
|
||||
}
|
||||
require.NoError(t, s.RecordIncompatible(IncompatibleEntry{FileKey: "mov-file", CreatedAt: now, Operation: "video thumbnail", Path: "/lib/a.mov", Format: "mov"}))
|
||||
|
||||
list, err := s.ListIncompatible()
|
||||
require.NoError(t, err)
|
||||
require.Len(t, list, 2)
|
||||
require.Equal(t, "/lib/clip.wmv", list[0].Path)
|
||||
require.Equal(t, int64(3), list[0].Occurrences)
|
||||
require.Equal(t, int64(1), list[1].Occurrences)
|
||||
|
||||
require.Error(t, s.RecordIncompatible(IncompatibleEntry{Path: "/x"}), "file key is required")
|
||||
|
||||
// Clear removes both the regressions and the incompatible files.
|
||||
require.NoError(t, s.Record(Entry{FileKey: "r", CreatedAt: now, Operation: "probe", Label: "error", Detail: "x", Format: "mp4"}))
|
||||
require.NoError(t, s.Clear())
|
||||
list, err = s.ListIncompatible()
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, list)
|
||||
entries, err := s.List()
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, entries)
|
||||
}
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/gtsteffaniak/filebrowser/backend/pkg/settings"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/utils"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/database/users"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/utils"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/pkg/settings"
|
||||
)
|
||||
|
||||
// PrepForFrontend builds API-safe ShareFrontend copies (never exposes backend Share fields).
|
||||
@@ -33,6 +33,9 @@ func copyShareFrontendFromShare(link *Share) ShareFrontend {
|
||||
},
|
||||
ShareColumns: snap.ShareColumns,
|
||||
}
|
||||
// Clients only ever see the presented identifier (alias when set, otherwise hash).
|
||||
out.Hash = PresentedHash(link)
|
||||
out.CustomHash = link.Alias
|
||||
if snap.AllowedUsernames != nil {
|
||||
out.AllowedUsernames = append([]string(nil), snap.AllowedUsernames...)
|
||||
}
|
||||
|
||||
@@ -43,15 +43,14 @@ type FrontendShareInfo struct {
|
||||
|
||||
// ShareLimits are bandwidth, access, and banner settings stored in share_settings JSON.
|
||||
type ShareLimits struct {
|
||||
MaxBandwidth int `json:"maxBandwidth,omitempty"`
|
||||
AllowedUsernames []string `json:"allowedUsernames,omitempty"`
|
||||
PerUserDownloadLimit bool `json:"perUserDownloadLimit,omitempty"`
|
||||
ExtractEmbeddedSubtitles bool `json:"extractEmbeddedSubtitles,omitempty"`
|
||||
DownloadsLimit int `json:"downloadsLimit,omitempty"`
|
||||
QuotaLimitBytes int64 `json:"quotaLimitBytes,omitempty"`
|
||||
HideFileExt string `json:"hideFileExt,omitempty"` // show hidden files based on extensions in shares
|
||||
Banner string `json:"banner,omitempty"`
|
||||
SourceName string `json:"source,omitempty"` // source display name for API; backend path is Share.SourcePath
|
||||
MaxBandwidth int `json:"maxBandwidth,omitempty"`
|
||||
AllowedUsernames []string `json:"allowedUsernames,omitempty"`
|
||||
PerUserDownloadLimit bool `json:"perUserDownloadLimit,omitempty"`
|
||||
DownloadsLimit int `json:"downloadsLimit,omitempty"`
|
||||
QuotaLimitBytes int64 `json:"quotaLimitBytes,omitempty"`
|
||||
HideFileExt string `json:"hideFileExt,omitempty"` // show hidden files based on extensions in shares
|
||||
Banner string `json:"banner,omitempty"`
|
||||
SourceName string `json:"source,omitempty"` // source display name for API; backend path is Share.SourcePath
|
||||
}
|
||||
|
||||
// ShareExpiryInput is POST body input used to compute ShareColumns.Expire (not persisted).
|
||||
@@ -68,13 +67,28 @@ type ShareSettings struct {
|
||||
}
|
||||
|
||||
// ShareColumns are SQL-backed identity and counter fields.
|
||||
// Hash is always the internal random identifier. Alias is an optional owner-chosen URL
|
||||
// identifier that resolves to Hash; it is never serialized directly (see PresentedHash).
|
||||
type ShareColumns struct {
|
||||
Hash string `json:"hash,omitempty" storm:"id,index"`
|
||||
Alias string `json:"-"`
|
||||
Path string `json:"path,omitempty"`
|
||||
Expire int64 `json:"expire"`
|
||||
Downloads int `json:"downloads,omitempty"`
|
||||
}
|
||||
|
||||
// PresentedHash returns the identifier shown to clients and used in share URLs:
|
||||
// the custom alias when one is set, otherwise the internal hash.
|
||||
func PresentedHash(link *Share) string {
|
||||
if link == nil {
|
||||
return ""
|
||||
}
|
||||
if link.Alias != "" {
|
||||
return link.Alias
|
||||
}
|
||||
return link.Hash
|
||||
}
|
||||
|
||||
// ShareEditable is the client-editable subset used in POST/PATCH bodies.
|
||||
type ShareEditable struct {
|
||||
FrontendShareInfo
|
||||
@@ -86,6 +100,9 @@ type ShareEditable struct {
|
||||
type ShareFrontend struct {
|
||||
ShareEditable
|
||||
ShareColumns
|
||||
// CustomHash is the owner-chosen alias (empty when the share uses its random hash). Hash already
|
||||
// carries the presented identifier, so this only tells the editor whether a custom value is set.
|
||||
CustomHash string `json:"customHash,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
PathExists bool `json:"pathExists,omitempty"`
|
||||
QuotaUsedBytes int64 `json:"quotaUsedBytes,omitempty"`
|
||||
@@ -97,9 +114,10 @@ type ShareFrontend struct {
|
||||
// Password omitted (nil) on update means keep the existing hash; empty string clears it.
|
||||
type SharePostBody struct {
|
||||
ShareEditable
|
||||
Password *string `json:"password,omitempty"`
|
||||
Hash string `json:"hash,omitempty"`
|
||||
Path string `json:"path,omitempty"`
|
||||
Password *string `json:"password,omitempty"`
|
||||
Hash string `json:"hash,omitempty"`
|
||||
Path string `json:"path,omitempty"`
|
||||
CustomHash string `json:"customHash,omitempty"`
|
||||
}
|
||||
|
||||
// EditableFromShare returns the client-editable subset of a persisted share.
|
||||
|
||||
-3
@@ -1,6 +1,3 @@
|
||||
//go:build !cgosql
|
||||
// +build !cgosql
|
||||
|
||||
package sql
|
||||
|
||||
import (
|
||||
@@ -1,10 +0,0 @@
|
||||
//go:build cgosql
|
||||
// +build cgosql
|
||||
|
||||
package sql
|
||||
|
||||
import (
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
const SqliteDriver = "sqlite3"
|
||||
@@ -0,0 +1,131 @@
|
||||
package sql
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gtsteffaniak/go-logger/logger"
|
||||
)
|
||||
|
||||
// supportsFTS5 reports whether the driver can create an FTS5 table with the trigram
|
||||
// tokenizer (SQLite >= 3.34 with FTS5 compiled in).
|
||||
func (db *IndexDB) supportsFTS5() bool {
|
||||
if _, err := db.Exec(`CREATE VIRTUAL TABLE IF NOT EXISTS temp.__fts_probe USING fts5(x, tokenize='trigram')`); err != nil {
|
||||
return false
|
||||
}
|
||||
_, _ = db.Exec(`DROP TABLE IF EXISTS temp.__fts_probe`)
|
||||
return true
|
||||
}
|
||||
|
||||
// ftsTableExists reports whether the FTS search table is present.
|
||||
func (db *IndexDB) ftsTableExists() bool {
|
||||
var n int
|
||||
if err := db.QueryRow(`SELECT count(*) FROM sqlite_master WHERE type = 'table' AND name = 'index_items_fts'`).Scan(&n); err != nil {
|
||||
return false
|
||||
}
|
||||
return n > 0
|
||||
}
|
||||
|
||||
// FTSReady reports whether the trigram search index is available for queries.
|
||||
func (db *IndexDB) FTSReady() bool {
|
||||
return db.ftsReady.Load()
|
||||
}
|
||||
|
||||
const ftsDDL = `
|
||||
CREATE VIRTUAL TABLE IF NOT EXISTS index_items_fts USING fts5(
|
||||
name, spath,
|
||||
content='index_items', content_rowid='rowid',
|
||||
tokenize='trigram', detail=none
|
||||
);
|
||||
CREATE TRIGGER IF NOT EXISTS index_items_fts_ai AFTER INSERT ON index_items BEGIN
|
||||
INSERT INTO index_items_fts(rowid, name, spath) VALUES (new.rowid, new.name, new.spath);
|
||||
END;
|
||||
CREATE TRIGGER IF NOT EXISTS index_items_fts_ad AFTER DELETE ON index_items BEGIN
|
||||
INSERT INTO index_items_fts(index_items_fts, rowid, name, spath) VALUES ('delete', old.rowid, old.name, old.spath);
|
||||
END;
|
||||
CREATE TRIGGER IF NOT EXISTS index_items_fts_au AFTER UPDATE OF name ON index_items
|
||||
WHEN old.name IS NOT new.name BEGIN
|
||||
INSERT INTO index_items_fts(index_items_fts, rowid, name, spath) VALUES ('delete', old.rowid, old.name, old.spath);
|
||||
INSERT INTO index_items_fts(rowid, name, spath) VALUES (new.rowid, new.name, new.spath);
|
||||
END;
|
||||
`
|
||||
|
||||
// syncSearchIndex creates the FTS5 trigram index when enabled and drops it when
|
||||
// disabled. The index is derived data: enabling it builds from existing rows (no
|
||||
// rescan), and disabling it removes the table and triggers.
|
||||
func (db *IndexDB) syncSearchIndex(enabled bool) {
|
||||
if !enabled {
|
||||
db.dropSearchIndex()
|
||||
return
|
||||
}
|
||||
if !db.supportsFTS5() {
|
||||
logger.Errorf("indexSqlConfig.fts5 is enabled but FTS5 trigram support is unavailable in this build; search will use the unindexed fallback.")
|
||||
db.ftsReady.Store(false)
|
||||
return
|
||||
}
|
||||
if err := db.ensureSpathColumn(); err != nil {
|
||||
logger.Errorf("failed to add the spath column (%v); search will use the unindexed fallback", err)
|
||||
db.ftsReady.Store(false)
|
||||
return
|
||||
}
|
||||
existed := db.ftsTableExists()
|
||||
if _, err := db.Exec(ftsDDL); err != nil {
|
||||
logger.Errorf("failed to create the FTS search index (%v); search will use the unindexed fallback", err)
|
||||
db.ftsReady.Store(false)
|
||||
return
|
||||
}
|
||||
if !existed {
|
||||
if _, err := db.Exec(`INSERT INTO index_items_fts(index_items_fts) VALUES('rebuild')`); err != nil {
|
||||
logger.Errorf("failed to populate the FTS search index (%v); search will use the unindexed fallback", err)
|
||||
db.ftsReady.Store(false)
|
||||
return
|
||||
}
|
||||
}
|
||||
db.ftsReady.Store(true)
|
||||
}
|
||||
|
||||
// dropSearchIndex removes the FTS table and its triggers (used when the feature is
|
||||
// disabled or the index needs a rebuild).
|
||||
func (db *IndexDB) dropSearchIndex() {
|
||||
db.ftsReady.Store(false)
|
||||
if !db.ftsTableExists() {
|
||||
return
|
||||
}
|
||||
if _, err := db.Exec(`
|
||||
DROP TRIGGER IF EXISTS index_items_fts_ai;
|
||||
DROP TRIGGER IF EXISTS index_items_fts_ad;
|
||||
DROP TRIGGER IF EXISTS index_items_fts_au;
|
||||
DROP TABLE IF EXISTS index_items_fts;
|
||||
`); err != nil {
|
||||
logger.Warningf("failed to drop the FTS search index: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// checkFTSHealth compares the FTS index against the base table and runs a cheap
|
||||
// internal consistency check. The full content check (rank=1) is far slower and is
|
||||
// skipped.
|
||||
func (db *IndexDB) checkFTSHealth() error {
|
||||
var items, docs int
|
||||
if err := db.QueryRow(`SELECT count(*) FROM index_items`).Scan(&items); err != nil {
|
||||
return fmt.Errorf("count index_items: %w", err)
|
||||
}
|
||||
if err := db.QueryRow(`SELECT count(*) FROM index_items_fts_docsize`).Scan(&docs); err != nil {
|
||||
return fmt.Errorf("count fts docsize: %w", err)
|
||||
}
|
||||
if items != docs {
|
||||
return fmt.Errorf("search index row mismatch: index_items=%d fts=%d", items, docs)
|
||||
}
|
||||
if _, err := db.Exec(`INSERT INTO index_items_fts(index_items_fts, rank) VALUES('integrity-check', 0)`); err != nil {
|
||||
return fmt.Errorf("fts integrity check: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// optimizeFTS merges the FTS index segments; call after bulk deletes or heavy churn.
|
||||
func (db *IndexDB) optimizeFTS() {
|
||||
if !db.FTSReady() {
|
||||
return
|
||||
}
|
||||
if _, err := db.Exec(`INSERT INTO index_items_fts(index_items_fts) VALUES('optimize')`); err != nil {
|
||||
logger.Warningf("FTS optimize failed: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -7,11 +7,12 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/database/sqlitebusy"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/pkg/settings"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/pkg/indexing/iteminfo"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/pkg/settings"
|
||||
"github.com/gtsteffaniak/go-logger/logger"
|
||||
)
|
||||
|
||||
@@ -19,6 +20,7 @@ import (
|
||||
// It wraps the underlying sql.DB connection and provides type-safe methods.
|
||||
type IndexDB struct {
|
||||
*TempDB
|
||||
ftsReady atomic.Bool
|
||||
}
|
||||
|
||||
func createIndexDB(name string, journalMode string, lockingMode string, batchSize int, cacheSizeMB int, disableReuse bool) (*IndexDB, error) {
|
||||
@@ -111,6 +113,17 @@ func NewIndexDB(name string, journalMode string, batchSize int, cacheSizeMB int,
|
||||
idxDB.Close()
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
// The FTS5 search index is optional (indexSqlConfig.fts5, default off). Enabling it
|
||||
// builds from existing rows; disabling it drops the table and triggers.
|
||||
idxDB.syncSearchIndex(settings.Config.Server.IndexSqlConfig.FTS5)
|
||||
if !disableReuse && !isNewDb && idxDB.FTSReady() {
|
||||
if err := idxDB.checkFTSHealth(); err != nil {
|
||||
logger.Warningf("[DB_INIT] FTS search index is unhealthy (%v); rebuilding", err)
|
||||
idxDB.dropSearchIndex()
|
||||
idxDB.syncSearchIndex(true)
|
||||
}
|
||||
}
|
||||
go idxDB.startPeriodicCleanup()
|
||||
return idxDB, isNewDb, nil
|
||||
}
|
||||
@@ -234,6 +247,7 @@ func (db *IndexDB) startPeriodicCleanup() {
|
||||
} else if deletedCount > 0 {
|
||||
logger.Infof("[DB_MAINTENANCE] Cleaned up %d stale index entries", deletedCount)
|
||||
}
|
||||
db.optimizeFTS()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,13 +273,45 @@ func (db *IndexDB) CreateIndexTable() error {
|
||||
CREATE INDEX IF NOT EXISTS idx_source_size ON index_items(source, size);
|
||||
CREATE INDEX IF NOT EXISTS idx_last_updated ON index_items(source, last_updated);
|
||||
`
|
||||
_, err := db.Exec(query)
|
||||
if err != nil {
|
||||
if _, err := db.Exec(query); err != nil {
|
||||
return err
|
||||
}
|
||||
return db.ensureCreatedTimeColumn()
|
||||
}
|
||||
|
||||
// ensureSpathColumn adds the generated spath column (source:path) used by the FTS
|
||||
// search index when it is missing from an existing table. PRAGMA table_xinfo is used
|
||||
// because table_info omits generated columns.
|
||||
func (db *IndexDB) ensureSpathColumn() error {
|
||||
rows, err := db.Query(`PRAGMA table_xinfo(index_items)`)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
found := false
|
||||
for rows.Next() {
|
||||
var cid, notNull, pk, hidden int
|
||||
var name, columnType string
|
||||
var defaultValue interface{}
|
||||
if scanErr := rows.Scan(&cid, &name, &columnType, ¬Null, &defaultValue, &pk, &hidden); scanErr != nil {
|
||||
rows.Close()
|
||||
return scanErr
|
||||
}
|
||||
if name == "spath" {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if rowsErr := rows.Err(); rowsErr != nil {
|
||||
rows.Close()
|
||||
return rowsErr
|
||||
}
|
||||
rows.Close()
|
||||
if found {
|
||||
return nil
|
||||
}
|
||||
_, err = db.Exec(`ALTER TABLE index_items ADD COLUMN spath TEXT GENERATED ALWAYS AS (source || ':' || path) VIRTUAL`)
|
||||
return err
|
||||
}
|
||||
|
||||
// ensureCreatedTimeColumn adds the created_time column to index_items when it is
|
||||
// missing, so databases created before the column existed are upgraded in place.
|
||||
func (db *IndexDB) ensureCreatedTimeColumn() error {
|
||||
|
||||
@@ -56,10 +56,17 @@ func testIndexSQLConfig(mode string) settings.IndexSqlConfig {
|
||||
BatchSize: 1000,
|
||||
CacheSizeMB: 32,
|
||||
DisableReuse: false,
|
||||
FTS5: true,
|
||||
StartupIntegrityCheck: mode,
|
||||
}
|
||||
}
|
||||
|
||||
func testIndexSQLConfigNoFTS(mode string) settings.IndexSqlConfig {
|
||||
cfg := testIndexSQLConfig(mode)
|
||||
cfg.FTS5 = false
|
||||
return cfg
|
||||
}
|
||||
|
||||
func TestNewIndexDB_StartupProbe_NewFile(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
pop := pushTestIndexConfig(t, dir, testIndexSQLConfig(settings.IndexStartupIntegrityProbe))
|
||||
@@ -129,3 +136,123 @@ func TestNewIndexDB_StartupOff(t *testing.T) {
|
||||
}
|
||||
defer db.Close()
|
||||
}
|
||||
|
||||
// TestNewIndexDB_ReusesHealthyDB checks that a matching schema is reused, not recreated.
|
||||
func TestNewIndexDB_ReusesHealthyDB(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
pop := pushTestIndexConfig(t, dir, testIndexSQLConfig(settings.IndexStartupIntegrityOff))
|
||||
defer pop()
|
||||
|
||||
db, isNew, err := NewIndexDB("reuse_ok", "OFF", 1000, 32, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !isNew {
|
||||
t.Fatalf("fresh database should report isNewDb=true")
|
||||
}
|
||||
if err = db.InsertItem("src1", "/a.txt", &iteminfo.FileInfo{
|
||||
Path: "/a.txt",
|
||||
ItemInfo: iteminfo.ItemInfo{Name: "a.txt", Type: "text/plain", ModTime: time.Unix(1, 0)},
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err = db.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
db2, isNew2, err := NewIndexDB("reuse_ok", "OFF", 1000, 32, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer db2.Close()
|
||||
if isNew2 {
|
||||
t.Fatalf("a healthy database should be reused, not recreated")
|
||||
}
|
||||
if !db2.FTSReady() {
|
||||
t.Fatalf("expected the FTS index to be ready on reuse")
|
||||
}
|
||||
}
|
||||
|
||||
// TestNewIndexDB_FTSDisabledWhenConfigOff checks that FTS is not created when disabled.
|
||||
func TestNewIndexDB_FTSDisabledWhenConfigOff(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
pop := pushTestIndexConfig(t, dir, testIndexSQLConfigNoFTS(settings.IndexStartupIntegrityOff))
|
||||
defer pop()
|
||||
|
||||
db, _, err := NewIndexDB("fts_off", "OFF", 1000, 32, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer db.Close()
|
||||
if db.FTSReady() {
|
||||
t.Fatalf("FTS should be disabled when indexSqlConfig.fts5 is false")
|
||||
}
|
||||
if db.ftsTableExists() {
|
||||
t.Fatalf("the FTS table should not exist when disabled")
|
||||
}
|
||||
}
|
||||
|
||||
// TestNewIndexDB_FTSToggleBuildsAndDrops checks that enabling FTS builds from existing
|
||||
// rows (no rescan) and disabling it removes the table.
|
||||
func TestNewIndexDB_FTSToggleBuildsAndDrops(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
|
||||
// Start with FTS off and insert a row.
|
||||
pop := pushTestIndexConfig(t, dir, testIndexSQLConfigNoFTS(settings.IndexStartupIntegrityOff))
|
||||
db, _, err := NewIndexDB("fts_toggle", "OFF", 1000, 32, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err = db.InsertItem("s1", "/a/report.txt", &iteminfo.FileInfo{
|
||||
Path: "/a/report.txt",
|
||||
ItemInfo: iteminfo.ItemInfo{Name: "report.txt", Type: "text/plain", ModTime: time.Unix(1, 0)},
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if db.FTSReady() {
|
||||
t.Fatalf("FTS should be off")
|
||||
}
|
||||
if err = db.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
pop()
|
||||
|
||||
// Reopen with FTS on: it should build from the existing row without a rescan.
|
||||
pop2 := pushTestIndexConfig(t, dir, testIndexSQLConfig(settings.IndexStartupIntegrityOff))
|
||||
db2, isNew, err := NewIndexDB("fts_toggle", "OFF", 1000, 32, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if isNew {
|
||||
t.Fatalf("reused database should not be recreated when enabling FTS")
|
||||
}
|
||||
if !db2.FTSReady() {
|
||||
t.Fatalf("FTS should be ready after enabling")
|
||||
}
|
||||
if err = db2.checkFTSHealth(); err != nil {
|
||||
t.Fatalf("health after enabling: %v", err)
|
||||
}
|
||||
filter := iteminfo.NameFilterForSearch(iteminfo.SearchOptions{Terms: []string{"report"}}, false, false)
|
||||
if got := runSearchItems(t, db2, "s1", "/", filter); !sameSet(got, []string{"/a/report.txt"}) {
|
||||
t.Fatalf("existing row should be searchable via FTS, got %v", got)
|
||||
}
|
||||
if err = db2.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
pop2()
|
||||
|
||||
// Disable again: the table and triggers should be dropped.
|
||||
pop3 := pushTestIndexConfig(t, dir, testIndexSQLConfigNoFTS(settings.IndexStartupIntegrityOff))
|
||||
defer pop3()
|
||||
db3, _, err := NewIndexDB("fts_toggle", "OFF", 1000, 32, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer db3.Close()
|
||||
if db3.FTSReady() {
|
||||
t.Fatalf("FTS should be off after disabling")
|
||||
}
|
||||
if db3.ftsTableExists() {
|
||||
t.Fatalf("the FTS table should be dropped when disabled")
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
package sql
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/gtsteffaniak/filebrowser/backend/pkg/indexing/iteminfo"
|
||||
)
|
||||
|
||||
// SearchItem represents a single search result row from the database
|
||||
@@ -19,19 +22,15 @@ type SearchItem struct {
|
||||
HasPreview bool
|
||||
}
|
||||
|
||||
// appendNameGlobSQL adds AND (name GLOB ? OR ...) or AND (name GLOB ? AND ...) when joinAnd is true.
|
||||
func appendNameGlobSQL(query string, args []interface{}, patterns []string, joinAnd, caseExact bool) (string, []interface{}) {
|
||||
// appendGlob adds "AND (col GLOB ? [OR/AND] ...)" when patterns is non-empty.
|
||||
func appendGlob(query string, args []interface{}, column string, patterns []string, joinAnd bool) (string, []interface{}) {
|
||||
if len(patterns) == 0 {
|
||||
return query, args
|
||||
}
|
||||
nameExpr := "name"
|
||||
if !caseExact {
|
||||
nameExpr = "lower(name)"
|
||||
}
|
||||
parts := make([]string, len(patterns))
|
||||
for i := range patterns {
|
||||
parts[i] = nameExpr + " GLOB ?"
|
||||
args = append(args, patterns[i])
|
||||
for i, p := range patterns {
|
||||
parts[i] = column + " GLOB ?"
|
||||
args = append(args, p)
|
||||
}
|
||||
join := " OR "
|
||||
if joinAnd {
|
||||
@@ -40,96 +39,173 @@ func appendNameGlobSQL(query string, args []interface{}, patterns []string, join
|
||||
return query + " AND (" + strings.Join(parts, join) + ")", args
|
||||
}
|
||||
|
||||
// appendLike adds "AND (col LIKE ? [OR/AND] ...)" when patterns is non-empty.
|
||||
func appendLike(query string, args []interface{}, column string, patterns []string, joinAnd bool) (string, []interface{}) {
|
||||
if len(patterns) == 0 {
|
||||
return query, args
|
||||
}
|
||||
parts := make([]string, len(patterns))
|
||||
for i, p := range patterns {
|
||||
parts[i] = column + " LIKE ?"
|
||||
args = append(args, p)
|
||||
}
|
||||
join := " OR "
|
||||
if joinAnd {
|
||||
join = " AND "
|
||||
}
|
||||
return query + " AND (" + strings.Join(parts, join) + ")", args
|
||||
}
|
||||
|
||||
// useFTSPath reports whether the trigram index can serve this name filter.
|
||||
func useFTSPath(db *IndexDB, filter *iteminfo.NameFilter) bool {
|
||||
return filter != nil && filter.UseFTS && db.FTSReady()
|
||||
}
|
||||
|
||||
// appendNamePrefilter narrows rows using the FTS trigram index (a superset of the
|
||||
// exact predicate). It is only valid in the FTS query path.
|
||||
func appendNamePrefilter(query string, args []interface{}, filter *iteminfo.NameFilter) (string, []interface{}) {
|
||||
if filter == nil || len(filter.FTS) == 0 {
|
||||
return query, args
|
||||
}
|
||||
if filter.PrefilterLike {
|
||||
return appendLike(query, args, "f.name", filter.FTS, filter.JoinAnd)
|
||||
}
|
||||
return appendGlob(query, args, "f.name", filter.FTS, filter.JoinAnd)
|
||||
}
|
||||
|
||||
// appendNameExact adds the exact name predicate applied to the base table. alias is
|
||||
// "" for the single-table query or "i." in the FTS join.
|
||||
func appendNameExact(query string, args []interface{}, filter *iteminfo.NameFilter, alias string) (string, []interface{}) {
|
||||
if filter == nil || len(filter.Exact) == 0 {
|
||||
return query, args
|
||||
}
|
||||
column := alias + "name"
|
||||
if filter.ExactLower {
|
||||
column = "lower(" + alias + "name)"
|
||||
}
|
||||
return appendGlob(query, args, column, filter.Exact, filter.JoinAnd)
|
||||
}
|
||||
|
||||
// SearchItems queries the database for items matching the search criteria for a single source.
|
||||
// When nameGlobPatterns is non-empty (and largest is false), rows are restricted with SQLite name GLOB ... OR ....
|
||||
// Returns rows that can be iterated to scan search results.
|
||||
func (db *IndexDB) SearchItems(source string, scope string, largest bool, nameGlobPatterns []string, nameGlobPatternsAnd, caseExact bool) (*sql.Rows, error) {
|
||||
// When the filter is usable and the FTS index is ready, rows are narrowed with the trigram
|
||||
// index and then filtered by the exact name predicate; otherwise the base table is scanned.
|
||||
func (db *IndexDB) SearchItems(ctx context.Context, source, scope string, largest bool, filter *iteminfo.NameFilter) (*sql.Rows, error) {
|
||||
if largest {
|
||||
query := `
|
||||
SELECT path, name, size, created_time, mod_time, type, is_dir, has_preview
|
||||
FROM index_items
|
||||
WHERE source = ?
|
||||
`
|
||||
args := []interface{}{source}
|
||||
if scope != "" {
|
||||
query += " AND path GLOB ?"
|
||||
args = append(args, iteminfo.EscapeGlobLiteral(scope)+"*")
|
||||
}
|
||||
query += " ORDER BY size DESC"
|
||||
return db.QueryContext(ctx, query, args...)
|
||||
}
|
||||
|
||||
if useFTSPath(db, filter) {
|
||||
query := `
|
||||
SELECT i.path, i.name, i.size, i.created_time, i.mod_time, i.type, i.is_dir, i.has_preview
|
||||
FROM index_items_fts f CROSS JOIN index_items i ON i.rowid = f.rowid
|
||||
WHERE i.source = ?
|
||||
`
|
||||
args := []interface{}{source}
|
||||
if scope != "" {
|
||||
query += " AND i.path GLOB ?"
|
||||
args = append(args, iteminfo.EscapeGlobLiteral(scope)+"*")
|
||||
}
|
||||
// Narrow by source+scope inside the global FTS index (superset; exact filters below).
|
||||
query += " AND f.spath LIKE ?"
|
||||
args = append(args, source+":"+scope+"%")
|
||||
query, args = appendNamePrefilter(query, args, filter)
|
||||
query, args = appendNameExact(query, args, filter, "i.")
|
||||
return db.QueryContext(ctx, query, args...)
|
||||
}
|
||||
|
||||
query := `
|
||||
SELECT path, name, size, created_time, mod_time, type, is_dir, has_preview
|
||||
FROM index_items
|
||||
WHERE source = ?
|
||||
`
|
||||
args := []interface{}{source}
|
||||
|
||||
// Apply scope filter
|
||||
if scope != "" {
|
||||
// Use GLOB for prefix matching which is supported by SQLite and efficient
|
||||
query += " AND path GLOB ?"
|
||||
args = append(args, scope+"*")
|
||||
args = append(args, iteminfo.EscapeGlobLiteral(scope)+"*")
|
||||
}
|
||||
|
||||
if !largest && len(nameGlobPatterns) > 0 {
|
||||
query, args = appendNameGlobSQL(query, args, nameGlobPatterns, nameGlobPatternsAnd, caseExact)
|
||||
}
|
||||
|
||||
if largest {
|
||||
query += " ORDER BY size DESC"
|
||||
}
|
||||
|
||||
return db.Query(query, args...)
|
||||
query, args = appendNameExact(query, args, filter, "")
|
||||
return db.QueryContext(ctx, query, args...)
|
||||
}
|
||||
|
||||
// SearchItemsMultiSource queries the database for items matching the search criteria across multiple sources.
|
||||
// When nameGlobPatterns is non-empty (and largest is false), restricts rows with SQLite name GLOB ... OR ....
|
||||
// Returns rows that can be iterated to scan search results.
|
||||
func (db *IndexDB) SearchItemsMultiSource(sources []string, sourceScopes map[string]string, largest bool, nameGlobPatterns []string, nameGlobPatternsAnd, caseExact bool) (*sql.Rows, error) {
|
||||
func (db *IndexDB) SearchItemsMultiSource(ctx context.Context, sources []string, sourceScopes map[string]string, largest bool, filter *iteminfo.NameFilter) (*sql.Rows, error) {
|
||||
if len(sources) == 0 {
|
||||
return nil, fmt.Errorf("at least one source is required")
|
||||
}
|
||||
|
||||
args := []interface{}{}
|
||||
placeholders := make([]string, len(sources))
|
||||
for i, source := range sources {
|
||||
placeholders[i] = "?"
|
||||
args = append(args, source)
|
||||
}
|
||||
sourceClause := "source = ?"
|
||||
if len(sources) > 1 {
|
||||
sourceClause = "source IN (" + strings.Join(placeholders, ",") + ")"
|
||||
}
|
||||
|
||||
// Per-source scope conditions (on the base table).
|
||||
scopeConditions := []string{}
|
||||
scopeArgs := []interface{}{}
|
||||
spathConditions := []string{}
|
||||
spathArgs := []interface{}{}
|
||||
for _, source := range sources {
|
||||
scope, hasScope := sourceScopes[source]
|
||||
if hasScope && scope != "" {
|
||||
scopeConditions = append(scopeConditions, "(source = ? AND path GLOB ?)")
|
||||
scopeArgs = append(scopeArgs, source, iteminfo.EscapeGlobLiteral(scope)+"*")
|
||||
spathConditions = append(spathConditions, "f.spath LIKE ?")
|
||||
spathArgs = append(spathArgs, source+":"+scope+"%")
|
||||
} else {
|
||||
scopeConditions = append(scopeConditions, "source = ?")
|
||||
scopeArgs = append(scopeArgs, source)
|
||||
}
|
||||
}
|
||||
|
||||
if largest {
|
||||
query := `
|
||||
SELECT source, path, name, size, created_time, mod_time, type, is_dir, has_preview
|
||||
FROM index_items
|
||||
WHERE ` + sourceClause
|
||||
query += " AND (" + strings.Join(scopeConditions, " OR ") + ")"
|
||||
query += " ORDER BY size DESC"
|
||||
allArgs := append(args, scopeArgs...)
|
||||
return db.QueryContext(ctx, query, allArgs...)
|
||||
}
|
||||
|
||||
if useFTSPath(db, filter) {
|
||||
query := `
|
||||
SELECT i.source, i.path, i.name, i.size, i.created_time, i.mod_time, i.type, i.is_dir, i.has_preview
|
||||
FROM index_items_fts f CROSS JOIN index_items i ON i.rowid = f.rowid
|
||||
WHERE i.` + sourceClause
|
||||
query += " AND (" + strings.Join(scopeConditions, " OR ") + ")"
|
||||
allArgs := append(args, scopeArgs...)
|
||||
if len(spathConditions) > 0 {
|
||||
query += " AND (" + strings.Join(spathConditions, " OR ") + ")"
|
||||
allArgs = append(allArgs, spathArgs...)
|
||||
}
|
||||
query, allArgs = appendNamePrefilter(query, allArgs, filter)
|
||||
query, allArgs = appendNameExact(query, allArgs, filter, "i.")
|
||||
return db.QueryContext(ctx, query, allArgs...)
|
||||
}
|
||||
|
||||
query := `
|
||||
SELECT source, path, name, size, created_time, mod_time, type, is_dir, has_preview
|
||||
FROM index_items
|
||||
`
|
||||
args := []interface{}{}
|
||||
whereClauses := []string{}
|
||||
|
||||
// Filter by sources using IN clause
|
||||
if len(sources) == 1 {
|
||||
whereClauses = append(whereClauses, "source = ?")
|
||||
args = append(args, sources[0])
|
||||
} else {
|
||||
placeholders := make([]string, len(sources))
|
||||
for i, source := range sources {
|
||||
placeholders[i] = "?"
|
||||
args = append(args, source)
|
||||
}
|
||||
whereClauses = append(whereClauses, "source IN ("+strings.Join(placeholders, ",")+")")
|
||||
}
|
||||
|
||||
// Apply scope filters - need OR conditions for each source+scope combination
|
||||
// Build conditions for each source: if it has a scope, filter by it; otherwise include all paths for that source
|
||||
scopeConditions := []string{}
|
||||
for _, source := range sources {
|
||||
scope, hasScope := sourceScopes[source]
|
||||
if hasScope && scope != "" {
|
||||
// Source has a scope - filter by it
|
||||
scopeConditions = append(scopeConditions, "(source = ? AND path GLOB ?)")
|
||||
args = append(args, source, scope+"*")
|
||||
} else {
|
||||
// Source has no scope or empty scope - include all paths for this source
|
||||
// The source IN clause already filters by source, so we just need to ensure
|
||||
// this source is included in the OR condition (which it already is via source IN)
|
||||
// We add a simple source check to make the OR condition work correctly
|
||||
scopeConditions = append(scopeConditions, "source = ?")
|
||||
args = append(args, source)
|
||||
}
|
||||
}
|
||||
if len(scopeConditions) > 0 {
|
||||
whereClauses = append(whereClauses, "("+strings.Join(scopeConditions, " OR ")+")")
|
||||
}
|
||||
|
||||
if len(whereClauses) > 0 {
|
||||
query += " WHERE " + strings.Join(whereClauses, " AND ")
|
||||
}
|
||||
|
||||
if !largest && len(nameGlobPatterns) > 0 {
|
||||
query, args = appendNameGlobSQL(query, args, nameGlobPatterns, nameGlobPatternsAnd, caseExact)
|
||||
}
|
||||
|
||||
if largest {
|
||||
query += " ORDER BY size DESC"
|
||||
}
|
||||
|
||||
return db.Query(query, args...)
|
||||
WHERE ` + sourceClause
|
||||
query += " AND (" + strings.Join(scopeConditions, " OR ") + ")"
|
||||
allArgs := append(args, scopeArgs...)
|
||||
query, allArgs = appendNameExact(query, allArgs, filter, "")
|
||||
return db.QueryContext(ctx, query, allArgs...)
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
package sql
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/gtsteffaniak/filebrowser/backend/pkg/indexing/iteminfo"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/pkg/settings"
|
||||
)
|
||||
|
||||
func newSearchTestDB(t *testing.T, name string) *IndexDB {
|
||||
t.Helper()
|
||||
dir := t.TempDir()
|
||||
pop := pushTestIndexConfig(t, dir, testIndexSQLConfig(settings.IndexStartupIntegrityOff))
|
||||
t.Cleanup(pop)
|
||||
db, _, err := NewIndexDB(name, "OFF", 1000, 32, false)
|
||||
if err != nil {
|
||||
t.Fatalf("NewIndexDB: %v", err)
|
||||
}
|
||||
t.Cleanup(func() { _ = db.Close() })
|
||||
return db
|
||||
}
|
||||
|
||||
func insertSearchItem(t *testing.T, db *IndexDB, source, path, name string) {
|
||||
t.Helper()
|
||||
info := &iteminfo.FileInfo{
|
||||
Path: path,
|
||||
ItemInfo: iteminfo.ItemInfo{
|
||||
Name: name,
|
||||
Type: "text/plain",
|
||||
ModTime: time.Unix(1, 0),
|
||||
},
|
||||
}
|
||||
if err := db.InsertItem(source, path, info); err != nil {
|
||||
t.Fatalf("InsertItem(%s): %v", path, err)
|
||||
}
|
||||
}
|
||||
|
||||
func runSearchItems(t *testing.T, db *IndexDB, source, scope string, filter *iteminfo.NameFilter) []string {
|
||||
t.Helper()
|
||||
rows, err := db.SearchItems(context.Background(), source, scope, false, filter)
|
||||
if err != nil {
|
||||
t.Fatalf("SearchItems: %v", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
var got []string
|
||||
for rows.Next() {
|
||||
var path, name string
|
||||
var size, createdTime, modTime int64
|
||||
var mimeType string
|
||||
var isDir, hasPreview bool
|
||||
if err := rows.Scan(&path, &name, &size, &createdTime, &modTime, &mimeType, &isDir, &hasPreview); err != nil {
|
||||
t.Fatalf("scan: %v", err)
|
||||
}
|
||||
got = append(got, path)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
t.Fatalf("rows: %v", err)
|
||||
}
|
||||
return got
|
||||
}
|
||||
|
||||
func seedSearchItems(t *testing.T, db *IndexDB) {
|
||||
t.Helper()
|
||||
insertSearchItem(t, db, "s1", "/a/Report 2024.pdf", "Report 2024.pdf")
|
||||
insertSearchItem(t, db, "s1", "/a/my_file.txt", "my_file.txt")
|
||||
insertSearchItem(t, db, "s1", "/a/myXfile.txt", "myXfile.txt")
|
||||
insertSearchItem(t, db, "s1", "/a/abc.txt", "abc.txt")
|
||||
insertSearchItem(t, db, "s1", "/b/report.txt", "report.txt")
|
||||
insertSearchItem(t, db, "s2", "/a/report-other.txt", "report-other.txt")
|
||||
}
|
||||
|
||||
func TestSearchItemsFTSDefault(t *testing.T) {
|
||||
db := newSearchTestDB(t, "search_fts_default")
|
||||
if !db.FTSReady() {
|
||||
t.Fatal("expected the FTS index to be ready")
|
||||
}
|
||||
seedSearchItems(t, db)
|
||||
|
||||
filter := iteminfo.NameFilterForSearch(iteminfo.SearchOptions{Terms: []string{"report"}}, false, false)
|
||||
if filter == nil || !filter.UseFTS {
|
||||
t.Fatalf("expected an FTS filter, got %#v", filter)
|
||||
}
|
||||
got := runSearchItems(t, db, "s1", "/", filter)
|
||||
want := []string{"/a/Report 2024.pdf", "/b/report.txt"}
|
||||
if !sameSet(got, want) {
|
||||
t.Fatalf("default search got %v, want %v", got, want)
|
||||
}
|
||||
|
||||
// The LIKE prefilter treats '_' as a wildcard; the exact lower(name) GLOB must remove
|
||||
// the false positive myXfile.txt.
|
||||
filter = iteminfo.NameFilterForSearch(iteminfo.SearchOptions{Terms: []string{"my_file"}}, false, false)
|
||||
got = runSearchItems(t, db, "s1", "/", filter)
|
||||
want = []string{"/a/my_file.txt"}
|
||||
if !sameSet(got, want) {
|
||||
t.Fatalf("underscore search got %v, want %v", got, want)
|
||||
}
|
||||
|
||||
// Scope is respected.
|
||||
filter = iteminfo.NameFilterForSearch(iteminfo.SearchOptions{Terms: []string{"report"}}, false, false)
|
||||
got = runSearchItems(t, db, "s1", "/b/", filter)
|
||||
want = []string{"/b/report.txt"}
|
||||
if !sameSet(got, want) {
|
||||
t.Fatalf("scoped search got %v, want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSearchItemsCaseExactAndWildcard(t *testing.T) {
|
||||
db := newSearchTestDB(t, "search_fts_modes")
|
||||
seedSearchItems(t, db)
|
||||
|
||||
// case:exact is case-sensitive.
|
||||
exact := iteminfo.NameFilterForSearch(iteminfo.SearchOptions{
|
||||
Terms: []string{"Report"},
|
||||
Conditions: map[string]bool{"exact": true},
|
||||
}, false, false)
|
||||
got := runSearchItems(t, db, "s1", "/", exact)
|
||||
want := []string{"/a/Report 2024.pdf"}
|
||||
if !sameSet(got, want) {
|
||||
t.Fatalf("case:exact got %v, want %v", got, want)
|
||||
}
|
||||
|
||||
// Wildcard stays on the legacy (case-insensitive) path.
|
||||
wild := iteminfo.NameFilterForSearch(iteminfo.SearchOptions{Terms: []string{"report*"}}, true, false)
|
||||
if wild == nil || wild.UseFTS {
|
||||
t.Fatalf("wildcard should use the legacy path, got %#v", wild)
|
||||
}
|
||||
got = runSearchItems(t, db, "s1", "/", wild)
|
||||
want = []string{"/a/Report 2024.pdf", "/b/report.txt"}
|
||||
if !sameSet(got, want) {
|
||||
t.Fatalf("wildcard got %v, want %v", got, want)
|
||||
}
|
||||
|
||||
// Too short for trigrams => legacy path, still correct.
|
||||
short := iteminfo.NameFilterForSearch(iteminfo.SearchOptions{Terms: []string{"ab"}}, false, false)
|
||||
if short == nil || short.UseFTS {
|
||||
t.Fatalf("short term should use the legacy path, got %#v", short)
|
||||
}
|
||||
got = runSearchItems(t, db, "s1", "/", short)
|
||||
want = []string{"/a/abc.txt"}
|
||||
if !sameSet(got, want) {
|
||||
t.Fatalf("short search got %v, want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSearchItemsMultiSource(t *testing.T) {
|
||||
db := newSearchTestDB(t, "search_fts_multi")
|
||||
seedSearchItems(t, db)
|
||||
|
||||
filter := iteminfo.NameFilterForSearch(iteminfo.SearchOptions{Terms: []string{"report"}}, false, false)
|
||||
rows, err := db.SearchItemsMultiSource(context.Background(),
|
||||
[]string{"s1", "s2"}, map[string]string{"s1": "/", "s2": "/"}, false, filter)
|
||||
if err != nil {
|
||||
t.Fatalf("SearchItemsMultiSource: %v", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
var got []string
|
||||
for rows.Next() {
|
||||
var source, path, name string
|
||||
var size, ct, mt int64
|
||||
var mime string
|
||||
var isDir, hasPreview bool
|
||||
if err := rows.Scan(&source, &path, &name, &size, &ct, &mt, &mime, &isDir, &hasPreview); err != nil {
|
||||
t.Fatalf("scan: %v", err)
|
||||
}
|
||||
got = append(got, source+":"+path)
|
||||
}
|
||||
want := []string{"s1:/a/Report 2024.pdf", "s1:/b/report.txt", "s2:/a/report-other.txt"}
|
||||
if !sameSet(got, want) {
|
||||
t.Fatalf("multi-source got %v, want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestSearchItemsQueryPlan guards the planner fix: the FTS table must drive the query.
|
||||
func TestSearchItemsQueryPlan(t *testing.T) {
|
||||
db := newSearchTestDB(t, "search_fts_plan")
|
||||
seedSearchItems(t, db)
|
||||
|
||||
plan, err := db.ExplainQueryPlan(
|
||||
`SELECT i.path FROM index_items_fts f CROSS JOIN index_items i ON i.rowid = f.rowid
|
||||
WHERE i.source = ? AND i.path GLOB ? AND f.spath LIKE ? AND f.name LIKE ? AND lower(i.name) GLOB ?`,
|
||||
"s1", "/%", "s1:/%", "%report%", "*report*",
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("ExplainQueryPlan: %v", err)
|
||||
}
|
||||
if !strings.Contains(plan, "VIRTUAL TABLE") {
|
||||
t.Fatalf("expected the FTS table to drive the query, plan:\n%s", plan)
|
||||
}
|
||||
if !strings.Contains(plan, "SEARCH i USING INTEGER PRIMARY KEY") {
|
||||
t.Fatalf("expected a rowid lookup into index_items, plan:\n%s", plan)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSearchItemsFTSHealthAfterDelete(t *testing.T) {
|
||||
db := newSearchTestDB(t, "search_fts_health")
|
||||
seedSearchItems(t, db)
|
||||
if err := db.checkFTSHealth(); err != nil {
|
||||
t.Fatalf("health before delete: %v", err)
|
||||
}
|
||||
if err := db.DeleteItem("s1", "/a/abc.txt", false); err != nil {
|
||||
t.Fatalf("DeleteItem: %v", err)
|
||||
}
|
||||
if err := db.checkFTSHealth(); err != nil {
|
||||
t.Fatalf("health after delete: %v", err)
|
||||
}
|
||||
// A name-changing upsert must also keep the index in sync.
|
||||
insertSearchItem(t, db, "s1", "/a/abc.txt", "renamed.txt")
|
||||
if err := db.checkFTSHealth(); err != nil {
|
||||
t.Fatalf("health after re-insert: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func sameSet(got, want []string) bool {
|
||||
if len(got) != len(want) {
|
||||
return false
|
||||
}
|
||||
set := make(map[string]int, len(got))
|
||||
for _, g := range got {
|
||||
set[g]++
|
||||
}
|
||||
for _, w := range want {
|
||||
set[w]--
|
||||
if set[w] < 0 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package sql
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"os"
|
||||
@@ -22,14 +23,6 @@ const (
|
||||
defaultCacheSizePages = -4096 // ~16MB
|
||||
)
|
||||
|
||||
func init() {
|
||||
if SqliteDriver == "sqlite3" {
|
||||
logger.Debugf("CGO SQLite driver initialized")
|
||||
} else {
|
||||
logger.Debugf("Default SQLite driver initialized")
|
||||
}
|
||||
}
|
||||
|
||||
// TempDB manages a temporary SQLite database for operations that need
|
||||
// to stream large datasets without loading everything into memory.
|
||||
// This can be used by any part of the codebase that needs temporary SQLite storage.
|
||||
@@ -227,7 +220,6 @@ func NewTempDB(id string, config ...*TempDBConfig) (*TempDB, error) {
|
||||
}
|
||||
|
||||
// Open SQLite database with basic connection string.
|
||||
// Driver is selected at compile time: "sqlite3" (CGO) or "sqlite" (pure Go).
|
||||
// busy_timeout is set in the DSN so every pooled connection honors it.
|
||||
db, err := sql.Open(SqliteDriver, sqlitebusy.WithBusyTimeout(tmpPath))
|
||||
if err != nil {
|
||||
@@ -405,6 +397,14 @@ func (t *TempDB) Query(query string, args ...interface{}) (*sql.Rows, error) {
|
||||
return t.db.Query(query, args...)
|
||||
}
|
||||
|
||||
// QueryContext executes a query that returns rows, honoring context cancellation so
|
||||
// an abandoned request interrupts the running statement instead of holding the connection.
|
||||
func (t *TempDB) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) {
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
return t.db.QueryContext(ctx, query, args...)
|
||||
}
|
||||
|
||||
// QueryRow executes a query that is expected to return at most one row.
|
||||
// This is a convenience method that handles locking.
|
||||
func (t *TempDB) QueryRow(query string, args ...interface{}) *sql.Row {
|
||||
|
||||
-3
@@ -1,6 +1,3 @@
|
||||
//go:build !cgosql
|
||||
// +build !cgosql
|
||||
|
||||
package sqldb
|
||||
|
||||
import (
|
||||
@@ -1,10 +0,0 @@
|
||||
//go:build cgosql
|
||||
// +build cgosql
|
||||
|
||||
package sqldb
|
||||
|
||||
import (
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
const SqliteDriver = "sqlite3"
|
||||
@@ -3,10 +3,16 @@ package sqldb
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
"github.com/gtsteffaniak/filebrowser/backend/pkg/settings"
|
||||
"github.com/gtsteffaniak/go-logger/logger"
|
||||
)
|
||||
|
||||
// currentSchemaVersion is the SQLite schema marker for this codebase.
|
||||
const currentSchemaVersion = 4
|
||||
// Version 5 clears the preview and thumbnail cache once, for databases upgraded from
|
||||
// a version older than v2.2.0. Earlier versions used different cache keys.
|
||||
// Version 6 adds shares.alias, the optional owner-chosen URL identifier that resolves to shares.hash.
|
||||
const currentSchemaVersion = 6
|
||||
|
||||
// Schema creates all tables for the SQLite database
|
||||
func createSchema(db *sql.DB) error {
|
||||
@@ -32,6 +38,7 @@ func createSchema(db *sql.DB) error {
|
||||
-- Shares (owner is user_id)
|
||||
CREATE TABLE IF NOT EXISTS shares (
|
||||
hash TEXT PRIMARY KEY,
|
||||
alias TEXT NOT NULL DEFAULT '',
|
||||
user_id TEXT NOT NULL,
|
||||
source TEXT NOT NULL,
|
||||
path TEXT NOT NULL,
|
||||
@@ -220,6 +227,16 @@ func runMigrations(db *sql.DB, fromVersion int) error {
|
||||
if err := addHashedTokenExpiryColumn(db); err != nil {
|
||||
return err
|
||||
}
|
||||
case 5:
|
||||
// Previews and thumbnails from earlier versions are regenerated on demand.
|
||||
// A failure to clear is logged and does not block startup.
|
||||
if err := settings.ClearPreviewDiskCache(); err != nil {
|
||||
logger.Warningf("failed to clear preview cache during upgrade to schema 6: %v", err)
|
||||
}
|
||||
case 6:
|
||||
if err := addShareAliasColumn(db); err != nil {
|
||||
return err
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("unknown schema version: %d", v)
|
||||
}
|
||||
@@ -309,6 +326,24 @@ func addHashedTokenExpiryColumn(db *sql.DB) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// addShareAliasColumn adds shares.alias and its unique partial index to databases created
|
||||
// before custom share aliases existed. Existing shares get an empty alias and keep working.
|
||||
func addShareAliasColumn(db *sql.DB) error {
|
||||
hasColumn, err := tableHasColumn(db, "shares", "alias")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !hasColumn {
|
||||
if _, err := db.Exec(`ALTER TABLE shares ADD COLUMN alias TEXT NOT NULL DEFAULT ''`); err != nil {
|
||||
return fmt.Errorf("failed to add shares.alias: %w", err)
|
||||
}
|
||||
}
|
||||
if _, err := db.Exec(`CREATE UNIQUE INDEX IF NOT EXISTS idx_shares_alias ON shares(alias) WHERE alias <> ''`); err != nil {
|
||||
return fmt.Errorf("failed to create shares alias index: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// tableHasColumn reports whether table/column exists in the current schema.
|
||||
func tableHasColumn(db *sql.DB, table, column string) (bool, error) {
|
||||
rows, err := db.Query(fmt.Sprintf("PRAGMA table_info(%s)", table))
|
||||
|
||||
@@ -48,6 +48,7 @@ func (s *SQLStore) GetShareByHash(hash string) (*share.Share, error) {
|
||||
|
||||
err := s.db.QueryRow(query, hash).Scan(
|
||||
&link.Hash,
|
||||
&link.Alias,
|
||||
&userIDStr,
|
||||
&link.SourcePath,
|
||||
&link.Path,
|
||||
@@ -81,6 +82,17 @@ func (s *SQLStore) GetShareByHash(hash string) (*share.Share, error) {
|
||||
return &link, nil
|
||||
}
|
||||
|
||||
// ShareHashExists reports whether an identifier is already used by a persisted share, either
|
||||
// as a share's internal hash or as its custom alias. Expired shares are included.
|
||||
func (s *SQLStore) ShareHashExists(identifier string) (bool, error) {
|
||||
var exists int
|
||||
err := s.db.QueryRow(`SELECT EXISTS(SELECT 1 FROM shares WHERE hash = ? OR alias = ?)`, identifier, identifier).Scan(&exists)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to check share hash: %w", err)
|
||||
}
|
||||
return exists == 1, nil
|
||||
}
|
||||
|
||||
// GetSharesByUserID retrieves all non-expired shares for an owner user id.
|
||||
func (s *SQLStore) GetSharesByUserID(userID uint64) ([]*share.Share, error) {
|
||||
now := time.Now().Unix()
|
||||
@@ -135,6 +147,7 @@ func (s *SQLStore) GetPermanentShare(source, path string, userID uint64) (*share
|
||||
|
||||
err := s.db.QueryRow(query, source, path, shareUserIDDB(userID)).Scan(
|
||||
&link.Hash,
|
||||
&link.Alias,
|
||||
&userIDStr,
|
||||
&link.SourcePath,
|
||||
&link.Path,
|
||||
@@ -210,11 +223,12 @@ func (s *SQLStore) SaveShare(link *share.Share) error {
|
||||
var args []any
|
||||
if hasLegacyToken {
|
||||
query = `INSERT OR REPLACE INTO shares
|
||||
(hash, user_id, source, path, expire, downloads, password_hash,
|
||||
(hash, alias, user_id, source, path, expire, downloads, password_hash,
|
||||
token, user_downloads, share_settings, version)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||
args = []any{
|
||||
link.Hash,
|
||||
link.Alias,
|
||||
shareUserIDDB(link.UserID),
|
||||
link.SourcePath,
|
||||
link.Path,
|
||||
@@ -228,11 +242,12 @@ func (s *SQLStore) SaveShare(link *share.Share) error {
|
||||
}
|
||||
} else {
|
||||
query = `INSERT OR REPLACE INTO shares
|
||||
(hash, user_id, source, path, expire, downloads, password_hash,
|
||||
(hash, alias, user_id, source, path, expire, downloads, password_hash,
|
||||
user_downloads, share_settings, version)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||
args = []any{
|
||||
link.Hash,
|
||||
link.Alias,
|
||||
shareUserIDDB(link.UserID),
|
||||
link.SourcePath,
|
||||
link.Path,
|
||||
@@ -314,6 +329,7 @@ func (s *SQLStore) scanShares(rows *sql.Rows) ([]*share.Share, error) {
|
||||
|
||||
err := rows.Scan(
|
||||
&link.Hash,
|
||||
&link.Alias,
|
||||
&userIDStr,
|
||||
&link.SourcePath,
|
||||
&link.Path,
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const shareSelectColumns = `hash, user_id, source, path, expire, downloads,
|
||||
const shareSelectColumns = `hash, alias, user_id, source, path, expire, downloads,
|
||||
password_hash, user_downloads, share_settings, version`
|
||||
|
||||
func sharesTableHasColumn(db *sql.DB, column string) (bool, error) {
|
||||
|
||||
@@ -58,6 +58,12 @@ func createLegacySharesDB(t *testing.T) *SQLStore {
|
||||
t.Fatalf("insert legacy share: %v", err)
|
||||
}
|
||||
|
||||
// Open() always runs the idempotent alias step after migrations; mirror that here so the
|
||||
// legacy-shaped table is writable with the current share columns.
|
||||
if err := addShareAliasColumn(store.db); err != nil {
|
||||
t.Fatalf("addShareAliasColumn: %v", err)
|
||||
}
|
||||
|
||||
return store
|
||||
}
|
||||
|
||||
|
||||
@@ -92,6 +92,13 @@ func NewSQLStoreWithOptions(dbPath string, opts NewSQLStoreOpts) (*SQLStore, boo
|
||||
}
|
||||
}
|
||||
|
||||
// The alias column and index are idempotent. Running them on every start keeps fresh
|
||||
// databases (which skip migrations) and upgraded databases consistent.
|
||||
if err = addShareAliasColumn(db); err != nil {
|
||||
db.Close()
|
||||
return nil, existingDb, err
|
||||
}
|
||||
|
||||
store := &SQLStore{db: db}
|
||||
|
||||
logger.Debugf("SQLite database initialized at %s", dbPath)
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package sqldb
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/adapters/fs/fileutils"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/pkg/settings"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// An existing database at schema 4 is upgraded to 5, which clears the preview
|
||||
// cache once. Reopening at schema 5 leaves new previews in place.
|
||||
func TestUpgradeFromBefore22ClearsPreviewCacheOnce(t *testing.T) {
|
||||
if fileutils.PermDir == 0 {
|
||||
fileutils.SetFsPermissions(0o644, 0o755)
|
||||
}
|
||||
prev := settings.Config.Server.CacheDir
|
||||
settings.Config.Server.CacheDir = t.TempDir()
|
||||
t.Cleanup(func() { settings.Config.Server.CacheDir = prev })
|
||||
|
||||
dbPath := filepath.Join(t.TempDir(), "database.db")
|
||||
store, _, err := NewSQLStoreWithOptions(dbPath, NewSQLStoreOpts{SkipQuickSetup: true})
|
||||
require.NoError(t, err)
|
||||
_, err = store.db.Exec("UPDATE schema_version SET version = 4")
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, store.db.Close())
|
||||
|
||||
previewDir := settings.PreviewDiskCacheDir()
|
||||
require.NoError(t, os.MkdirAll(previewDir, fileutils.PermDir))
|
||||
oldPreview := filepath.Join(previewDir, "old.jpg")
|
||||
require.NoError(t, os.WriteFile(oldPreview, []byte("old"), 0o644))
|
||||
|
||||
store, _, err = NewSQLStoreWithOptions(dbPath, NewSQLStoreOpts{SkipQuickSetup: true})
|
||||
require.NoError(t, err)
|
||||
version, err := getSchemaVersion(store.db)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, currentSchemaVersion, version)
|
||||
_, err = os.Stat(oldPreview)
|
||||
require.True(t, os.IsNotExist(err), "preview from before v2.2.0 is cleared")
|
||||
|
||||
newPreview := filepath.Join(previewDir, "new.jpg")
|
||||
require.NoError(t, os.WriteFile(newPreview, []byte("new"), 0o644))
|
||||
require.NoError(t, store.db.Close())
|
||||
|
||||
store, _, err = NewSQLStoreWithOptions(dbPath, NewSQLStoreOpts{SkipQuickSetup: true})
|
||||
require.NoError(t, err)
|
||||
defer store.db.Close()
|
||||
_, err = os.Stat(newPreview)
|
||||
require.NoError(t, err, "a reopen at the current schema does not clear again")
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package sqldb
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/database/users"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/pkg/settings"
|
||||
)
|
||||
|
||||
// A stored user with no profile (saved before profiles existed) must load the admin default
|
||||
// for custom share URLs, not the zero value.
|
||||
func TestFinishUserLoadProfilelessUserInheritsCustomShareDefault(t *testing.T) {
|
||||
prev := settings.Config.UserDefaults.Account.AllowCustomShareURL
|
||||
t.Cleanup(func() { settings.Config.UserDefaults.Account.AllowCustomShareURL = prev })
|
||||
|
||||
load := func(t *testing.T, def *bool) bool {
|
||||
t.Helper()
|
||||
settings.Config.UserDefaults.Account.AllowCustomShareURL = def
|
||||
u := &users.User{Username: "legacy"}
|
||||
if err := finishUserLoad(u, []byte(`{}`)); err != nil {
|
||||
t.Fatalf("finishUserLoad: %v", err)
|
||||
}
|
||||
return u.AllowCustomShareURL
|
||||
}
|
||||
|
||||
f := false
|
||||
tr := true
|
||||
if got := load(t, &f); got {
|
||||
t.Fatal("admin default false was not applied to a profile-less stored user")
|
||||
}
|
||||
if got := load(t, &tr); !got {
|
||||
t.Fatal("admin default true was not applied to a profile-less stored user")
|
||||
}
|
||||
if got := load(t, nil); got {
|
||||
t.Fatal("unset default must fall back to disabled for a profile-less stored user")
|
||||
}
|
||||
}
|
||||
@@ -16,13 +16,13 @@ import (
|
||||
type UserData struct {
|
||||
Password string `json:"password,omitempty"`
|
||||
// BackendScopes: persisted source access (Name = backend path). JSON key "scopes" is historical on-disk.
|
||||
BackendScopes []users.BackendScope `json:"backendScopes"`
|
||||
Tokens map[string]users.AuthToken `json:"tokens,omitempty"`
|
||||
TOTPSecret string `json:"totpSecret,omitempty"`
|
||||
TOTPNonce string `json:"totpNonce,omitempty"`
|
||||
LoginMethod users.LoginMethod `json:"loginMethod"`
|
||||
OtpEnabled bool `json:"otpEnabled"`
|
||||
Version int `json:"version"`
|
||||
BackendScopes []users.BackendScope `json:"backendScopes"`
|
||||
Tokens map[string]users.AuthToken `json:"tokens,omitempty"`
|
||||
TOTPSecret string `json:"totpSecret,omitempty"`
|
||||
TOTPNonce string `json:"totpNonce,omitempty"`
|
||||
LoginMethod users.LoginMethod `json:"loginMethod"`
|
||||
OtpEnabled bool `json:"otpEnabled"`
|
||||
Version int `json:"version"`
|
||||
ShowFirstLogin bool `json:"showFirstLogin"`
|
||||
PinnedItems users.PinnedItems `json:"pinnedItems,omitempty"`
|
||||
Profile json.RawMessage `json:"profile,omitempty"`
|
||||
@@ -108,12 +108,17 @@ func finishUserLoad(user *users.User, userDataJSON []byte) error {
|
||||
if err := applyProfileSettingsOverlay(user, userData.Settings); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if len(userData.Settings) > 0 {
|
||||
var legacySettings users.NonAdminEditable
|
||||
if err := json.Unmarshal(userData.Settings, &legacySettings); err != nil {
|
||||
return fmt.Errorf("parse legacy settings: %w", err)
|
||||
} else {
|
||||
// Records saved before profiles existed carry no account defaults, so they take the
|
||||
// admin default instead of the zero value.
|
||||
user.AllowCustomShareURL = settings.DefaultAllowCustomShareURL()
|
||||
if len(userData.Settings) > 0 {
|
||||
var legacySettings users.NonAdminEditable
|
||||
if err := json.Unmarshal(userData.Settings, &legacySettings); err != nil {
|
||||
return fmt.Errorf("parse legacy settings: %w", err)
|
||||
}
|
||||
user.NonAdminEditable = legacySettings
|
||||
}
|
||||
user.NonAdminEditable = legacySettings
|
||||
}
|
||||
if userData.Share {
|
||||
user.Permissions.Share = true
|
||||
|
||||
@@ -25,8 +25,8 @@ func TestFinishUserLoad_legacyProfileRowPreservesAbsentSettingsFields(t *testing
|
||||
if !loaded.ShowFirstLogin {
|
||||
t.Fatal("expected top-level showFirstLogin to be preserved when settings omits it")
|
||||
}
|
||||
if !loaded.DarkMode {
|
||||
t.Fatal("expected profile darkMode=true")
|
||||
if !loaded.DarkMode.IsDark() {
|
||||
t.Fatalf("expected profile darkMode=true, got %q", loaded.DarkMode)
|
||||
}
|
||||
if len(loaded.PasskeyCredentials) != 0 {
|
||||
t.Fatalf("expected no passkeys when settings omits passkeyCredentials, got %#v", loaded.PasskeyCredentials)
|
||||
@@ -95,7 +95,7 @@ func TestUserDataRoundTrip_profileSettingsOverlay(t *testing.T) {
|
||||
LoginMethod: users.LoginMethodPassword,
|
||||
ShowFirstLogin: true,
|
||||
NonAdminEditable: users.NonAdminEditable{
|
||||
DarkMode: true,
|
||||
DarkMode: users.DarkModeDark,
|
||||
SidebarLinks: []users.SidebarLink{
|
||||
{Name: "Home", Target: "/files"},
|
||||
},
|
||||
|
||||
@@ -14,7 +14,7 @@ var ErrBusy = errors.New("sqlite database is busy or locked")
|
||||
|
||||
// WithBusyTimeout appends the busy_timeout connection parameter to dsn so that
|
||||
// every connection in the pool honors the timeout. Both supported drivers
|
||||
// (mattn/go-sqlite3 and modernc.org/sqlite) apply the parameter at
|
||||
// (modernc.org/sqlite) applies the parameter at
|
||||
// connection-open time, unlike a one-off PRAGMA which only configures the
|
||||
// single connection that database/sql happens to pick.
|
||||
func WithBusyTimeout(dsn string) string {
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
//go:build cgosql
|
||||
// +build cgosql
|
||||
|
||||
package sqlitebusy
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
sqlite3 "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
const testDriver = "sqlite3"
|
||||
|
||||
// driverErrorCode returns the driver's extended result code for err, so tests
|
||||
// can assert which busy/locked variant was produced. mattn reports the
|
||||
// extended code in Error.ExtendedCode.
|
||||
func driverErrorCode(err error) int {
|
||||
var sqliteErr sqlite3.Error
|
||||
if errors.As(err, &sqliteErr) {
|
||||
return int(sqliteErr.ExtendedCode)
|
||||
}
|
||||
return -1
|
||||
}
|
||||
-3
@@ -1,6 +1,3 @@
|
||||
//go:build !cgosql
|
||||
// +build !cgosql
|
||||
|
||||
package sqlitebusy
|
||||
|
||||
import (
|
||||
-3
@@ -1,6 +1,3 @@
|
||||
//go:build !cgosql
|
||||
// +build !cgosql
|
||||
|
||||
package sqlitebusy
|
||||
|
||||
import (
|
||||
@@ -1,21 +0,0 @@
|
||||
//go:build cgosql
|
||||
// +build cgosql
|
||||
|
||||
package sqlitebusy
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
sqlite3 "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
// isBusyOrLocked reports whether err is a SQLITE_BUSY or SQLITE_LOCKED error
|
||||
// from the CGO (mattn/go-sqlite3) driver. Error.Code is already the primary
|
||||
// result code; extended codes are reported separately in Error.ExtendedCode.
|
||||
func isBusyOrLocked(err error) bool {
|
||||
var sqliteErr sqlite3.Error
|
||||
if !errors.As(err, &sqliteErr) {
|
||||
return false
|
||||
}
|
||||
return sqliteErr.Code == sqlite3.ErrBusy || sqliteErr.Code == sqlite3.ErrLocked
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package users
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// DarkMode is the user's theme preference: "auto" (follow the client's
|
||||
// system preference), "dark", or "light". It unmarshals from legacy JSON
|
||||
// booleans for backward compatibility with existing stored users.
|
||||
type DarkMode string
|
||||
|
||||
const (
|
||||
DarkModeAuto DarkMode = "auto"
|
||||
DarkModeDark DarkMode = "dark"
|
||||
DarkModeLight DarkMode = "light"
|
||||
)
|
||||
|
||||
// UnmarshalJSON accepts legacy boolean values (true -> dark, false -> light),
|
||||
// the tri-state strings ("auto", "dark", "light"), and null (unset).
|
||||
func (d *DarkMode) UnmarshalJSON(data []byte) error {
|
||||
var v interface{}
|
||||
if err := json.Unmarshal(data, &v); err != nil {
|
||||
return err
|
||||
}
|
||||
switch val := v.(type) {
|
||||
case nil:
|
||||
*d = ""
|
||||
case bool:
|
||||
if val {
|
||||
*d = DarkModeDark
|
||||
} else {
|
||||
*d = DarkModeLight
|
||||
}
|
||||
case string:
|
||||
switch DarkMode(strings.ToLower(val)) {
|
||||
case "":
|
||||
*d = ""
|
||||
case "true":
|
||||
// Some YAML decoders cast scalar booleans to strings.
|
||||
*d = DarkModeDark
|
||||
case "false":
|
||||
*d = DarkModeLight
|
||||
case DarkModeAuto:
|
||||
*d = DarkModeAuto
|
||||
case DarkModeDark:
|
||||
*d = DarkModeDark
|
||||
case DarkModeLight:
|
||||
*d = DarkModeLight
|
||||
default:
|
||||
return fmt.Errorf("invalid darkMode value %q: must be \"auto\", \"dark\" or \"light\"", val)
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("invalid darkMode value: must be a boolean or one of \"auto\", \"dark\", \"light\"")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsDark reports the effective boolean value for server-side rendering
|
||||
// contexts. "auto" cannot be resolved server-side; callers that can know the
|
||||
// client preference should handle DarkModeAuto explicitly.
|
||||
func (d DarkMode) IsDark() bool {
|
||||
return d == DarkModeDark
|
||||
}
|
||||
|
||||
// Or returns d unless it is unset (""), in which case it returns def.
|
||||
func (d DarkMode) Or(def DarkMode) DarkMode {
|
||||
if d == "" {
|
||||
return def
|
||||
}
|
||||
return d
|
||||
}
|
||||
@@ -98,13 +98,13 @@ type WebAuthnCredential struct {
|
||||
|
||||
type AuthToken struct {
|
||||
MinimalAuthToken
|
||||
Key string `json:"key,omitempty"` // for backward compatibility
|
||||
Token string `json:"token,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
BelongsTo uint64 `json:"belongsTo,omitempty"` // legacy stored metadata only, never trusted for auth; identity is always the hashed_tokens lookup
|
||||
IssuedAt int64 `json:"issuedAt,omitempty"`
|
||||
ExpiresAt int64 `json:"expiresAt,omitempty"`
|
||||
Key string `json:"key,omitempty"` // for backward compatibility
|
||||
Token string `json:"token,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
BelongsTo uint64 `json:"belongsTo,omitempty"` // legacy stored metadata only, never trusted for auth; identity is always the hashed_tokens lookup
|
||||
IssuedAt int64 `json:"issuedAt,omitempty"`
|
||||
ExpiresAt int64 `json:"expiresAt,omitempty"`
|
||||
// Minimal distinguishes owner-inheriting tokens from customized caps. Nil means legacy (infer from stored permissions).
|
||||
Minimal *bool `json:"minimal,omitempty"`
|
||||
Permissions Permissions `json:"Permissions,omitempty"`
|
||||
@@ -233,18 +233,23 @@ type Preview struct {
|
||||
// FrontendUser holds fields safe to return from user APIs (embedded on User).
|
||||
type FrontendUser struct {
|
||||
NonAdminEditable
|
||||
DisableSettings bool `json:"disableSettings"`
|
||||
Username string `json:"username"`
|
||||
FrontendScopes []FrontendScope `json:"scopes"`
|
||||
LockPassword bool `json:"lockPassword"`
|
||||
RequirePasswordChange bool `json:"requirePasswordChange"`
|
||||
Permissions Permissions `json:"permissions"` // global: admin, api, share, realtime
|
||||
SourcePermissions map[string]SourceFilePermissions `json:"sourcePermissions,omitempty"` // deprecated: use scopes[].permissions
|
||||
LoginMethod LoginMethod `json:"loginMethod"`
|
||||
OtpEnabled bool `json:"otpEnabled"`
|
||||
ShowFirstLogin bool `json:"showFirstLogin"`
|
||||
EffectiveToolAccess map[string]bool `json:"effectiveToolAccess,omitempty"`
|
||||
Perm Permissions `json:"perm,omitzero"`
|
||||
DisableSettings bool `json:"disableSettings"`
|
||||
// AllowCustomShareURL and MaxConcurrentTranscodes are admin-set: they stay out of
|
||||
// NonAdminEditable so a user cannot grant themselves the capability through a
|
||||
// self-service PATCH.
|
||||
AllowCustomShareURL bool `json:"allowCustomShareURL"`
|
||||
MaxConcurrentTranscodes int `json:"maxConcurrentTranscodes"`
|
||||
Username string `json:"username"`
|
||||
FrontendScopes []FrontendScope `json:"scopes"`
|
||||
LockPassword bool `json:"lockPassword"`
|
||||
RequirePasswordChange bool `json:"requirePasswordChange"`
|
||||
Permissions Permissions `json:"permissions"` // global: admin, api, share, realtime
|
||||
SourcePermissions map[string]SourceFilePermissions `json:"sourcePermissions,omitempty"` // deprecated: use scopes[].permissions
|
||||
LoginMethod LoginMethod `json:"loginMethod"`
|
||||
OtpEnabled bool `json:"otpEnabled"`
|
||||
ShowFirstLogin bool `json:"showFirstLogin"`
|
||||
EffectiveToolAccess map[string]bool `json:"effectiveToolAccess,omitempty"`
|
||||
Perm Permissions `json:"perm,omitzero"`
|
||||
}
|
||||
|
||||
// PinnedItems maps source filesystem path -> index directory path -> pinned item names.
|
||||
@@ -305,7 +310,7 @@ type NonAdminEditable struct {
|
||||
DeleteWithoutConfirming bool `json:"deleteWithoutConfirming"` // delete files without confirmation
|
||||
Preview Preview `json:"preview"`
|
||||
StickySidebar bool `json:"stickySidebar"` // keep sidebar open when navigating
|
||||
DarkMode bool `json:"darkMode"` // should dark mode be enabled
|
||||
DarkMode DarkMode `json:"darkMode"` // theme preference: "auto" (follow system), "dark", or "light"
|
||||
Password string `json:"password,omitempty"`
|
||||
Locale string `json:"locale"` // language to use: eg. de, en, or fr
|
||||
ViewMode string `json:"viewMode"` // view mode to use: eg. normal, list, grid, or compact
|
||||
@@ -336,6 +341,7 @@ type NonAdminEditable struct {
|
||||
HideFilesInTree bool `json:"hideFilesInTree"` // hide files in the sidebar tree navigation, when true, will show only directories.
|
||||
DeleteAfterArchive bool `json:"deleteAfterArchive"` // delete source files after successful creation/extraction of archives
|
||||
PreferEditorForMarkdown bool `json:"preferEditorForMarkdown"` // prefer editor first for markdown files instead of the Markdown Viewer
|
||||
PreferEditorForHtml bool `json:"preferEditorForHtml"` // prefer editor first for HTML files instead of the HTML viewer
|
||||
PromptRightCloseButton bool `json:"promptRightCloseButton"` // show the prompts close button on the right
|
||||
ShowFirstLogin bool `json:"showFirstLogin"`
|
||||
PasskeyCredentials []WebAuthnCredential `json:"passkeyCredentials,omitempty"`
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package embeddedpreview
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"image"
|
||||
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/imagemeta"
|
||||
// Decoders for embedded images, so Usable can decode every format the preview path accepts.
|
||||
_ "image/gif"
|
||||
_ "image/jpeg"
|
||||
_ "image/png"
|
||||
|
||||
_ "golang.org/x/image/webp"
|
||||
)
|
||||
|
||||
// maxPixels caps width x height of an embedded image. It is the same limit imagemeta uses to choose
|
||||
// among embedded JPEGs. The read cap bounds encoded bytes, not decoded size: a small file can declare
|
||||
// huge dimensions, and decoding allocates every pixel (about 4 bytes each as RGBA).
|
||||
const maxPixels = imagemeta.MaxPreviewPixels
|
||||
|
||||
// WithinPixelBudget reports whether an image of the given size can be decoded safely.
|
||||
func WithinPixelBudget(width, height int) bool {
|
||||
if width <= 0 || height <= 0 {
|
||||
return false
|
||||
}
|
||||
return int64(width)*int64(height) <= maxPixels
|
||||
}
|
||||
|
||||
// Usable reports whether data is an image that is safe to use as a preview. The header must
|
||||
// declare a size within the pixel budget, and the whole image must decode. The budget check runs
|
||||
// first, so an oversized header is rejected without allocating pixels. The full decode catches
|
||||
// truncated or corrupt files, which a header check alone accepts.
|
||||
func Usable(data []byte) bool {
|
||||
cfg, _, err := image.DecodeConfig(bytes.NewReader(data))
|
||||
if err != nil || !WithinPixelBudget(cfg.Width, cfg.Height) {
|
||||
return false
|
||||
}
|
||||
_, _, err = image.Decode(bytes.NewReader(data))
|
||||
return err == nil
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package embeddedpreview
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/binary"
|
||||
"hash/crc32"
|
||||
"image"
|
||||
"image/png"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// pngBytes encodes a w x h image. Keep w x h small in tests.
|
||||
func pngBytes(t *testing.T, w, h int) []byte {
|
||||
t.Helper()
|
||||
var buf bytes.Buffer
|
||||
require.NoError(t, png.Encode(&buf, image.NewGray(image.Rect(0, 0, w, h))))
|
||||
return buf.Bytes()
|
||||
}
|
||||
|
||||
// pngWithDeclaredSize rewrites the IHDR of a small PNG to declare w x h, with a valid CRC.
|
||||
// The pixel data is still the small original, so the file is truncated relative to its header.
|
||||
func pngWithDeclaredSize(t *testing.T, w, h uint32) []byte {
|
||||
t.Helper()
|
||||
data := pngBytes(t, 1, 1)
|
||||
binary.BigEndian.PutUint32(data[16:20], w)
|
||||
binary.BigEndian.PutUint32(data[20:24], h)
|
||||
binary.BigEndian.PutUint32(data[29:33], crc32.ChecksumIEEE(data[12:29]))
|
||||
return data
|
||||
}
|
||||
|
||||
func TestWithinPixelBudget(t *testing.T) {
|
||||
require.True(t, WithinPixelBudget(1, 1))
|
||||
require.True(t, WithinPixelBudget(8000, 5000))
|
||||
require.False(t, WithinPixelBudget(0, 100))
|
||||
require.False(t, WithinPixelBudget(100, -1))
|
||||
require.False(t, WithinPixelBudget(10000, 10000))
|
||||
}
|
||||
|
||||
func TestUsable_acceptsValidImage(t *testing.T) {
|
||||
require.True(t, Usable(pngBytes(t, 64, 64)))
|
||||
}
|
||||
|
||||
func TestUsable_rejectsGarbage(t *testing.T) {
|
||||
require.False(t, Usable([]byte("not an image")))
|
||||
}
|
||||
|
||||
func TestUsable_rejectsOversizedHeader(t *testing.T) {
|
||||
require.False(t, Usable(pngWithDeclaredSize(t, 10000, 10000)))
|
||||
}
|
||||
|
||||
// The header parses and fits the budget, but the pixel data is cut short.
|
||||
func TestUsable_rejectsTruncatedImage(t *testing.T) {
|
||||
full := pngBytes(t, 256, 256)
|
||||
truncated := full[:len(full)/2]
|
||||
_, _, err := image.DecodeConfig(bytes.NewReader(truncated))
|
||||
require.NoError(t, err, "header must still parse for this test to mean anything")
|
||||
require.False(t, Usable(truncated))
|
||||
}
|
||||
|
||||
// The same PNG bytes the Playwright remote-image stub serves. They must be a real image.
|
||||
func TestUsable_playwrightStubPNG(t *testing.T) {
|
||||
stub, err := base64.StdEncoding.DecodeString("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==")
|
||||
require.NoError(t, err)
|
||||
require.True(t, Usable(stub))
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
// Package embeddedpreview returns a preview image that is already stored inside a file:
|
||||
// camera RAW and HEIC previews, and thumbnails or merged images in zip-based documents and
|
||||
// project files. Every extractor returns ErrNotFound when a file has no usable image, so callers
|
||||
// fall back to go-media, ffmpeg, and the document pipeline. Nothing is extracted to disk.
|
||||
package embeddedpreview
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/gtsteffaniak/filebrowser/backend/internal/imagemeta"
|
||||
"github.com/gtsteffaniak/filebrowser/backend/pkg/indexing/iteminfo"
|
||||
)
|
||||
|
||||
// ErrNotFound means the file has no embedded image this package can read.
|
||||
var ErrNotFound = errors.New("no embedded preview image found")
|
||||
|
||||
// Result is the embedded image and how the caller should treat it.
|
||||
type Result struct {
|
||||
Data []byte
|
||||
// Ext is the lowercase extension of the embedded image, for example ".png".
|
||||
Ext string
|
||||
// Oriented is true when EXIF orientation applies to Data (camera RAW and HEIC).
|
||||
Oriented bool
|
||||
}
|
||||
|
||||
// Extractor reads one family of formats.
|
||||
type Extractor interface {
|
||||
Supports(ext, mimetype string) bool
|
||||
Extract(ctx context.Context, path string) (Result, error)
|
||||
}
|
||||
|
||||
var extractors = []Extractor{
|
||||
rawExtractor{},
|
||||
zipExtractor{exts: []string{".kra"}, pick: pickKrita},
|
||||
zipExtractor{exts: []string{".ora"}, pick: pickORA},
|
||||
zipExtractor{exts: []string{".sketch"}, pick: pickSketch},
|
||||
zipExtractor{exts: []string{".mscz"}, pick: pickMuseScore},
|
||||
zipExtractor{exts: []string{".odt", ".ods", ".odp", ".odg"}, pick: pickODF},
|
||||
zipExtractor{exts: []string{".docx", ".xlsx", ".pptx"}, pick: pickOOXML},
|
||||
zipExtractor{exts: []string{".cbz"}, pick: pickCBZ},
|
||||
zipExtractor{exts: []string{".xps"}, pick: pickXPS},
|
||||
}
|
||||
|
||||
func lookup(name, mimetype string) (Extractor, bool) {
|
||||
ext := strings.ToLower(filepath.Ext(name))
|
||||
for _, e := range extractors {
|
||||
if e.Supports(ext, mimetype) {
|
||||
return e, true
|
||||
}
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// Supports reports whether an extractor in this package handles the file.
|
||||
func Supports(name, mimetype string) bool {
|
||||
_, ok := lookup(name, mimetype)
|
||||
return ok
|
||||
}
|
||||
|
||||
// Extract returns the embedded image for the file at path. It returns ErrNotFound when the
|
||||
// format has no extractor or the file has no usable image.
|
||||
func Extract(ctx context.Context, name, mimetype, path string) (Result, error) {
|
||||
e, ok := lookup(name, mimetype)
|
||||
if !ok {
|
||||
return Result{}, ErrNotFound
|
||||
}
|
||||
if err := ctx.Err(); err != nil {
|
||||
return Result{}, err
|
||||
}
|
||||
return e.Extract(ctx, path)
|
||||
}
|
||||
|
||||
// rawExtractor wraps imagemeta for camera RAW and HEIC files.
|
||||
type rawExtractor struct{}
|
||||
|
||||
func (rawExtractor) Supports(ext, mimetype string) bool {
|
||||
return iteminfo.IsRawImage(ext) || strings.HasPrefix(mimetype, "image/hei")
|
||||
}
|
||||
|
||||
func (rawExtractor) Extract(ctx context.Context, path string) (Result, error) {
|
||||
data, err := imagemeta.ExtractEmbeddedPreview(ctx, path)
|
||||
if err != nil {
|
||||
return Result{}, err
|
||||
}
|
||||
if len(data) == 0 {
|
||||
return Result{}, ErrNotFound
|
||||
}
|
||||
return Result{Data: data, Ext: ".jpg", Oriented: true}, nil
|
||||
}
|
||||
|
||||
// zipExtractor handles a zip container, using pick to choose the entry.
|
||||
type zipExtractor struct {
|
||||
exts []string
|
||||
pick func(zr *zip.Reader) (Result, error)
|
||||
}
|
||||
|
||||
func (z zipExtractor) Supports(ext, _ string) bool {
|
||||
for _, e := range z.exts {
|
||||
if e == ext {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (z zipExtractor) Extract(_ context.Context, path string) (Result, error) {
|
||||
zr, err := zip.OpenReader(path)
|
||||
if err != nil {
|
||||
return Result{}, fmt.Errorf("open archive: %w", err)
|
||||
}
|
||||
defer zr.Close()
|
||||
return z.pick(&zr.Reader)
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
package embeddedpreview
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
"bytes"
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// writeZip builds a zip container with the given entries and returns its path.
|
||||
func writeZip(t *testing.T, name string, entries map[string][]byte) string {
|
||||
t.Helper()
|
||||
var buf bytes.Buffer
|
||||
zw := zip.NewWriter(&buf)
|
||||
for entryName, data := range entries {
|
||||
w, err := zw.Create(entryName)
|
||||
require.NoError(t, err)
|
||||
_, err = w.Write(data)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
require.NoError(t, zw.Close())
|
||||
p := filepath.Join(t.TempDir(), name)
|
||||
require.NoError(t, os.WriteFile(p, buf.Bytes(), 0o644))
|
||||
return p
|
||||
}
|
||||
|
||||
func extract(t *testing.T, name, path string) (Result, error) {
|
||||
t.Helper()
|
||||
return Extract(context.Background(), name, "application/octet-stream", path)
|
||||
}
|
||||
|
||||
func TestKrita_mergedImageThenPreview(t *testing.T) {
|
||||
merged, preview := pngBytes(t, 8, 8), pngBytes(t, 4, 4)
|
||||
p := writeZip(t, "art.kra", map[string][]byte{
|
||||
"mergedimage.png": merged,
|
||||
"preview.png": preview,
|
||||
})
|
||||
res, err := extract(t, "art.kra", p)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, merged, res.Data)
|
||||
require.Equal(t, ".png", res.Ext)
|
||||
require.False(t, res.Oriented)
|
||||
|
||||
p = writeZip(t, "fallback.kra", map[string][]byte{"preview.png": preview})
|
||||
res, err = extract(t, "fallback.kra", p)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, preview, res.Data)
|
||||
}
|
||||
|
||||
// An oversized mergedimage.png must not hide a usable preview.png.
|
||||
func TestKrita_oversizedMergedImageFallsBackToPreview(t *testing.T) {
|
||||
preview := pngBytes(t, 4, 4)
|
||||
p := writeZip(t, "big.kra", map[string][]byte{
|
||||
"mergedimage.png": pngWithDeclaredSize(t, 10000, 10000),
|
||||
"preview.png": preview,
|
||||
})
|
||||
res, err := extract(t, "big.kra", p)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, preview, res.Data)
|
||||
}
|
||||
|
||||
// A truncated mergedimage.png is skipped the same way.
|
||||
func TestKrita_truncatedMergedImageFallsBackToPreview(t *testing.T) {
|
||||
full := pngBytes(t, 256, 256)
|
||||
preview := pngBytes(t, 4, 4)
|
||||
p := writeZip(t, "cut.kra", map[string][]byte{
|
||||
"mergedimage.png": full[:len(full)/2],
|
||||
"preview.png": preview,
|
||||
})
|
||||
res, err := extract(t, "cut.kra", p)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, preview, res.Data)
|
||||
}
|
||||
|
||||
func TestKrita_missingImage(t *testing.T) {
|
||||
p := writeZip(t, "art.kra", map[string][]byte{"maindoc.xml": []byte("<doc/>")})
|
||||
_, err := extract(t, "art.kra", p)
|
||||
require.ErrorIs(t, err, ErrNotFound)
|
||||
}
|
||||
|
||||
func TestCBZ_firstPageInNaturalOrder(t *testing.T) {
|
||||
p := writeZip(t, "comic.cbz", map[string][]byte{
|
||||
"page10.jpg": []byte("ten"),
|
||||
"page2.jpg": []byte("two"),
|
||||
"__MACOSX/._page1.jpg": []byte("junk"),
|
||||
".hidden.png": []byte("hidden"),
|
||||
"notes.txt": []byte("text"),
|
||||
})
|
||||
res, err := extract(t, "comic.cbz", p)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []byte("two"), res.Data)
|
||||
require.Equal(t, ".jpg", res.Ext)
|
||||
}
|
||||
|
||||
func TestCBZ_noImages(t *testing.T) {
|
||||
p := writeZip(t, "comic.cbz", map[string][]byte{"readme.txt": []byte("x")})
|
||||
_, err := extract(t, "comic.cbz", p)
|
||||
require.ErrorIs(t, err, ErrNotFound)
|
||||
}
|
||||
|
||||
const xpsRels = `<?xml version="1.0" encoding="utf-8"?>
|
||||
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
||||
<Relationship Id="rId1" Type="http://schemas.microsoft.com/xps/2005/06/thumbnail" Target="/Metadata/Thumbnail.jpeg"/>
|
||||
<Relationship Id="rId2" Type="http://schemas.microsoft.com/xps/2005/06/fixedrepresentation" Target="/FixedDocSeq.fdseq"/>
|
||||
</Relationships>`
|
||||
|
||||
func TestXPS_thumbnailRelationship(t *testing.T) {
|
||||
p := writeZip(t, "doc.xps", map[string][]byte{
|
||||
"_rels/.rels": []byte(xpsRels),
|
||||
"Metadata/Thumbnail.jpeg": []byte("thumb"),
|
||||
})
|
||||
res, err := extract(t, "doc.xps", p)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []byte("thumb"), res.Data)
|
||||
require.Equal(t, ".jpeg", res.Ext)
|
||||
}
|
||||
|
||||
func TestXPS_noThumbnail(t *testing.T) {
|
||||
rels := `<Relationships><Relationship Type="http://schemas.microsoft.com/xps/2005/06/fixedrepresentation" Target="/FixedDocSeq.fdseq"/></Relationships>`
|
||||
p := writeZip(t, "doc.xps", map[string][]byte{"_rels/.rels": []byte(rels)})
|
||||
_, err := extract(t, "doc.xps", p)
|
||||
require.ErrorIs(t, err, ErrNotFound)
|
||||
}
|
||||
|
||||
func TestOpenDocument_thumbnail(t *testing.T) {
|
||||
p := writeZip(t, "letter.odt", map[string][]byte{"Thumbnails/thumbnail.png": []byte("odf")})
|
||||
res, err := extract(t, "letter.odt", p)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []byte("odf"), res.Data)
|
||||
require.Equal(t, ".png", res.Ext)
|
||||
}
|
||||
|
||||
func TestOOXML_thumbnailVariants(t *testing.T) {
|
||||
for _, entry := range []string{"docProps/thumbnail.jpeg", "docProps/thumbnail.png"} {
|
||||
p := writeZip(t, "deck.pptx", map[string][]byte{entry: []byte("thumb")})
|
||||
res, err := extract(t, "deck.pptx", p)
|
||||
require.NoError(t, err, entry)
|
||||
require.Equal(t, []byte("thumb"), res.Data)
|
||||
}
|
||||
p := writeZip(t, "sheet.xlsx", map[string][]byte{"xl/workbook.xml": []byte("<x/>")})
|
||||
_, err := extract(t, "sheet.xlsx", p)
|
||||
require.ErrorIs(t, err, ErrNotFound)
|
||||
}
|
||||
|
||||
func TestORA_mergedImage(t *testing.T) {
|
||||
p := writeZip(t, "paint.ora", map[string][]byte{"mergedimage.png": []byte("ora")})
|
||||
res, err := extract(t, "paint.ora", p)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []byte("ora"), res.Data)
|
||||
}
|
||||
|
||||
func TestSketch_preview(t *testing.T) {
|
||||
p := writeZip(t, "ui.sketch", map[string][]byte{"previews/preview.png": []byte("sketch")})
|
||||
res, err := extract(t, "ui.sketch", p)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []byte("sketch"), res.Data)
|
||||
}
|
||||
|
||||
func TestMuseScore_thumbnail(t *testing.T) {
|
||||
p := writeZip(t, "score.mscz", map[string][]byte{"Thumbnails/thumbnail.png": []byte("score")})
|
||||
res, err := extract(t, "score.mscz", p)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []byte("score"), res.Data)
|
||||
}
|
||||
|
||||
func TestExtract_notAZip(t *testing.T) {
|
||||
p := filepath.Join(t.TempDir(), "broken.cbz")
|
||||
require.NoError(t, os.WriteFile(p, []byte("not a zip"), 0o644))
|
||||
_, err := extract(t, "broken.cbz", p)
|
||||
require.Error(t, err)
|
||||
}
|
||||
|
||||
func TestExtract_unsupportedFormat(t *testing.T) {
|
||||
_, err := extract(t, "notes.txt", "/nonexistent")
|
||||
require.ErrorIs(t, err, ErrNotFound)
|
||||
}
|
||||
|
||||
func TestSupports(t *testing.T) {
|
||||
require.True(t, Supports("art.kra", "application/octet-stream"))
|
||||
require.True(t, Supports("letter.ODT", ""))
|
||||
require.True(t, Supports("photo.cr2", "image/x-canon-cr2"))
|
||||
require.True(t, Supports("photo.heic", "image/heic"))
|
||||
require.False(t, Supports("photo.jpg", "image/jpeg"))
|
||||
require.False(t, Supports("movie.mp4", "video/mp4"))
|
||||
}
|
||||
|
||||
func TestNaturalKey_ordersNumbers(t *testing.T) {
|
||||
require.Less(t, naturalKey("page2.jpg"), naturalKey("page10.jpg"))
|
||||
require.Less(t, naturalKey("page002.jpg"), naturalKey("page010.jpg"))
|
||||
}
|
||||
|
||||
// Digit runs longer than any fixed padding width must not panic and must still sort numerically.
|
||||
func TestNaturalKey_longDigitRuns(t *testing.T) {
|
||||
long := strings.Repeat("9", 40)
|
||||
require.NotPanics(t, func() { naturalKey("p" + long + ".jpg") })
|
||||
require.Less(t, naturalKey("page10.jpg"), naturalKey("page"+long+".jpg"))
|
||||
require.Less(t, naturalKey("page"+long+".jpg"), naturalKey("page1"+long+".jpg"))
|
||||
}
|
||||
|
||||
func TestCBZ_longPageNumbersDoNotPanic(t *testing.T) {
|
||||
long := strings.Repeat("1", 25)
|
||||
p := writeZip(t, "comic.cbz", map[string][]byte{
|
||||
"page" + long + ".jpg": []byte("long"),
|
||||
"page2.jpg": []byte("two"),
|
||||
})
|
||||
res, err := extract(t, "comic.cbz", p)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []byte("two"), res.Data)
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package embeddedpreview
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"io"
|
||||
"path"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// maxEntryBytes caps how much of one embedded entry is read. It matches the 20 MB limit
|
||||
// the text pipeline uses (adapters/fs/files), and guards against zip bombs.
|
||||
const maxEntryBytes = 20 << 20
|
||||
|
||||
var imageExts = map[string]bool{".jpg": true, ".jpeg": true, ".png": true, ".webp": true, ".gif": true}
|
||||
|
||||
// pickFirstEntry returns the first named entry that exists and has data.
|
||||
func pickFirstEntry(zr *zip.Reader, names ...string) (Result, error) {
|
||||
return pickFirstValidEntry(zr, func([]byte) bool { return true }, names...)
|
||||
}
|
||||
|
||||
// pickFirstValidEntry returns the first named entry that exists, has data, and passes valid.
|
||||
// A candidate that fails valid is skipped, so the next name is tried.
|
||||
func pickFirstValidEntry(zr *zip.Reader, valid func([]byte) bool, names ...string) (Result, error) {
|
||||
for _, name := range names {
|
||||
f := findEntry(zr, name)
|
||||
if f == nil {
|
||||
continue
|
||||
}
|
||||
data, err := readEntry(f)
|
||||
if err != nil || len(data) == 0 || !valid(data) {
|
||||
continue
|
||||
}
|
||||
return Result{Data: data, Ext: strings.ToLower(path.Ext(f.Name))}, nil
|
||||
}
|
||||
return Result{}, ErrNotFound
|
||||
}
|
||||
|
||||
// Krita stores a flattened composite at the root. preview.png is the fallback.
|
||||
// An oversized or corrupt mergedimage.png is skipped in favour of preview.png.
|
||||
func pickKrita(zr *zip.Reader) (Result, error) {
|
||||
return pickFirstValidEntry(zr, Usable, "mergedimage.png", "preview.png")
|
||||
}
|
||||
|
||||
// OpenRaster stores a merged image at the root and an optional thumbnail.
|
||||
func pickORA(zr *zip.Reader) (Result, error) {
|
||||
return pickFirstEntry(zr, "mergedimage.png", "Thumbnails/thumbnail.png")
|
||||
}
|
||||
|
||||
// Sketch stores a preview next to the document data.
|
||||
func pickSketch(zr *zip.Reader) (Result, error) {
|
||||
return pickFirstEntry(zr, "previews/preview.png")
|
||||
}
|
||||
|
||||
// MuseScore writes a thumbnail into the score container.
|
||||
func pickMuseScore(zr *zip.Reader) (Result, error) {
|
||||
return pickFirstEntry(zr, "Thumbnails/thumbnail.png")
|
||||
}
|
||||
|
||||
// OpenDocument (ODT, ODS, ODP, ODG) writes Thumbnails/thumbnail.png when the app saves one.
|
||||
func pickODF(zr *zip.Reader) (Result, error) {
|
||||
return pickFirstEntry(zr, "Thumbnails/thumbnail.png")
|
||||
}
|
||||
|
||||
// Office Open XML (DOCX, XLSX, PPTX) keeps an optional thumbnail under docProps.
|
||||
func pickOOXML(zr *zip.Reader) (Result, error) {
|
||||
return pickFirstEntry(zr, "docProps/thumbnail.jpeg", "docProps/thumbnail.jpg", "docProps/thumbnail.png")
|
||||
}
|
||||
|
||||
// CBZ cover: the first image in natural page order, ignoring macOS metadata and hidden files.
|
||||
func pickCBZ(zr *zip.Reader) (Result, error) {
|
||||
var pages []*zip.File
|
||||
for _, f := range zr.File {
|
||||
if f.FileInfo().IsDir() || strings.HasPrefix(f.Name, "__MACOSX/") {
|
||||
continue
|
||||
}
|
||||
base := path.Base(f.Name)
|
||||
if strings.HasPrefix(base, ".") {
|
||||
continue
|
||||
}
|
||||
if imageExts[strings.ToLower(path.Ext(base))] {
|
||||
pages = append(pages, f)
|
||||
}
|
||||
}
|
||||
sort.SliceStable(pages, func(i, j int) bool {
|
||||
return naturalKey(pages[i].Name) < naturalKey(pages[j].Name)
|
||||
})
|
||||
for _, f := range pages {
|
||||
data, err := readEntry(f)
|
||||
if err != nil || len(data) == 0 {
|
||||
continue
|
||||
}
|
||||
return Result{Data: data, Ext: strings.ToLower(path.Ext(f.Name))}, nil
|
||||
}
|
||||
return Result{}, ErrNotFound
|
||||
}
|
||||
|
||||
const xpsThumbnailRel = "http://schemas.microsoft.com/xps/2005/06/thumbnail"
|
||||
|
||||
type xpsRelationships struct {
|
||||
Relationships []struct {
|
||||
Type string `xml:"Type,attr"`
|
||||
Target string `xml:"Target,attr"`
|
||||
} `xml:"Relationship"`
|
||||
}
|
||||
|
||||
// XPS thumbnails are optional. The package-level relationship in _rels/.rels points at one when present.
|
||||
func pickXPS(zr *zip.Reader) (Result, error) {
|
||||
rels := findEntry(zr, "_rels/.rels")
|
||||
if rels == nil {
|
||||
return Result{}, ErrNotFound
|
||||
}
|
||||
relData, err := readEntry(rels)
|
||||
if err != nil {
|
||||
return Result{}, ErrNotFound
|
||||
}
|
||||
var parsed xpsRelationships
|
||||
if err := xml.Unmarshal(relData, &parsed); err != nil {
|
||||
return Result{}, ErrNotFound
|
||||
}
|
||||
for _, rel := range parsed.Relationships {
|
||||
if rel.Type != xpsThumbnailRel {
|
||||
continue
|
||||
}
|
||||
target := strings.TrimPrefix(rel.Target, "/")
|
||||
ext := strings.ToLower(path.Ext(target))
|
||||
if ext != ".jpg" && ext != ".jpeg" && ext != ".png" {
|
||||
continue
|
||||
}
|
||||
return pickFirstEntry(zr, target)
|
||||
}
|
||||
return Result{}, ErrNotFound
|
||||
}
|
||||
|
||||
// findEntry matches the exact name first, then case-insensitively (some writers vary the case).
|
||||
func findEntry(zr *zip.Reader, name string) *zip.File {
|
||||
for _, f := range zr.File {
|
||||
if f.Name == name {
|
||||
return f
|
||||
}
|
||||
}
|
||||
for _, f := range zr.File {
|
||||
if strings.EqualFold(f.Name, name) {
|
||||
return f
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// readEntry reads one zip entry, refusing anything larger than maxEntryBytes.
|
||||
func readEntry(f *zip.File) ([]byte, error) {
|
||||
if f.UncompressedSize64 > maxEntryBytes {
|
||||
return nil, fmt.Errorf("embedded entry %q is too large", f.Name)
|
||||
}
|
||||
rc, err := f.Open()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rc.Close()
|
||||
data, err := io.ReadAll(io.LimitReader(rc, maxEntryBytes+1))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(data) > maxEntryBytes {
|
||||
return nil, fmt.Errorf("embedded entry %q is too large", f.Name)
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
var digitRun = regexp.MustCompile(`\d+`)
|
||||
|
||||
// naturalKey makes "page2" sort before "page10" by rewriting each digit run as a
|
||||
// fixed-width length prefix followed by the run without leading zeros. Comparing those
|
||||
// keys orders runs numerically, and it works for runs of any length (no padding that
|
||||
// could go negative on long digit runs).
|
||||
func naturalKey(name string) string {
|
||||
return digitRun.ReplaceAllStringFunc(strings.ToLower(name), func(d string) string {
|
||||
digits := strings.TrimLeft(d, "0")
|
||||
if digits == "" {
|
||||
digits = "0"
|
||||
}
|
||||
return fmt.Sprintf("%06d%s", len(digits), digits)
|
||||
})
|
||||
}
|
||||
Loaded 100 of 811 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user