Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1179a6f94 | ||
|
|
e03b6b1fd4 | ||
|
|
4dcac7f690 | ||
|
|
9825b4317b | ||
|
|
33847b1440 |
@@ -0,0 +1,98 @@
|
|||||||
|
# Gitea twin of .github/workflows/docker-publish.yml. Gitea runs only .gitea/workflows/ once this
|
||||||
|
# folder exists, and GitHub never reads it.
|
||||||
|
#
|
||||||
|
# Publishes to IPCR on watch.nsl.sh instead of ghcr.io:
|
||||||
|
# push ipcr-push-85-17-246-67.nip.io/metadec.eth/<repo>:<tag> docker login as metadec.eth with the
|
||||||
|
# IPCR_PUSH_TOKEN secret (the metadec.eth namespace token from the IPCR dashboard)
|
||||||
|
# pull ipcr-watch.nsl.sh/ipns/metadec.eth/metadec.eth/<repo>:<tag> anonymous
|
||||||
|
# The push goes to ipcr-push-85-17-246-67.nip.io, the box's own address, not ipcr-push-watch.nsl.sh: Cloudflare fronts
|
||||||
|
# *.watch.nsl.sh and refuses any request over 100 MB (413), which a large image layer is.
|
||||||
|
# That host's certificate is signed by the box's private Mesh Router CA, given to buildkit from
|
||||||
|
# the IPCR_CA_PEM repo variable. docker login would make the job's Docker daemon check the
|
||||||
|
# certificate without that CA, so the login is written straight into ~/.docker/config.json.
|
||||||
|
# The runner's job image (node:22-bookworm) has no docker CLI, so the static one is
|
||||||
|
# installed first; buildx installs itself. No `type=gha` cache: the runner has none.
|
||||||
|
|
||||||
|
name: Build and Push Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
tag:
|
||||||
|
description: 'Tag for the image (optional, defaults to sha)'
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
meta_core_version:
|
||||||
|
description: 'meta-core version to use (default: latest)'
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
default: 'latest'
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: ipcr-push-85-17-246-67.nip.io
|
||||||
|
IPCR_PULL: ipcr-watch.nsl.sh/ipns/metadec.eth
|
||||||
|
IMAGE_NAME: metadec.eth/${{ github.event.repository.name }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install Docker CLI
|
||||||
|
run: curl -fsSL https://download.docker.com/linux/static/stable/x86_64/docker-28.5.1.tgz | tar -xz -C /usr/local/bin --strip-components=1 docker/docker
|
||||||
|
|
||||||
|
- name: Trust the Mesh Router CA
|
||||||
|
run: printf '%s\n' "$IPCR_CA_PEM" > /tmp/ipcr-ca.pem
|
||||||
|
env:
|
||||||
|
IPCR_CA_PEM: ${{ vars.IPCR_CA_PEM }}
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
version: latest
|
||||||
|
buildkitd-config-inline: |
|
||||||
|
[registry."${{ env.REGISTRY }}"]
|
||||||
|
ca = ["/tmp/ipcr-ca.pem"]
|
||||||
|
|
||||||
|
- name: Log in to IPCR
|
||||||
|
env:
|
||||||
|
IPCR_PUSH_TOKEN: ${{ secrets.IPCR_PUSH_TOKEN }}
|
||||||
|
run: |
|
||||||
|
mkdir -p ~/.docker
|
||||||
|
printf '{"auths":{"%s":{"auth":"%s"}}}\n' "$REGISTRY" "$(printf 'metadec.eth:%s' "$IPCR_PUSH_TOKEN" | base64 -w0)" > ~/.docker/config.json
|
||||||
|
|
||||||
|
- name: Extract metadata (tags, labels)
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
tags: |
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
# A fix to release 1.2.3 is tagged v1.2.3.1: four numbers are not semver, so
|
||||||
|
# the pattern above makes no tag for it; this one does (image tag 1.2.3.1).
|
||||||
|
type=match,pattern=v(\d+\.\d+\.\d+\.\d+),group=1
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=sha,prefix=
|
||||||
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
type=raw,value=${{ inputs.tag }},enable=${{ inputs.tag != '' }}
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
build-args: |
|
||||||
|
META_CORE_IMAGE=${{ env.IPCR_PULL }}/metadec.eth/meta-core:${{ inputs.meta_core_version || 'latest' }}
|
||||||
@@ -50,6 +50,9 @@ jobs:
|
|||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
tags: |
|
tags: |
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
|
# A fix to release 1.2.3 is tagged v1.2.3.1: four numbers are not semver, so
|
||||||
|
# the pattern above makes no tag for it; this one does (image tag 1.2.3.1).
|
||||||
|
type=match,pattern=v(\d+\.\d+\.\d+\.\d+),group=1
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
type=sha,prefix=
|
type=sha,prefix=
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
|||||||
@@ -102,6 +102,85 @@ export interface MeshNodeConfig {
|
|||||||
payload?: () => { status?: string; resources: BeaconResource[] };
|
payload?: () => { status?: string; resources: BeaconResource[] };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** How a discovered resource relates to this consumer (Scan card). */
|
||||||
|
export type ScanState = 'configured' | 'addable' | 'bound-elsewhere';
|
||||||
|
|
||||||
|
export interface ScanCandidate {
|
||||||
|
instance: string;
|
||||||
|
name: string;
|
||||||
|
version?: string;
|
||||||
|
resourceId: string;
|
||||||
|
caps: string[];
|
||||||
|
/** endpoints.http — what the consumer would register. */
|
||||||
|
url: string;
|
||||||
|
binds?: string;
|
||||||
|
state: ScanState;
|
||||||
|
/** The list entry that already holds this URL (state `configured`). */
|
||||||
|
configuredAs?: string;
|
||||||
|
/** A list-safe name to register it under. */
|
||||||
|
suggestedName: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Same JSON as meta-feeder-sdk `beacon::ScanReport`. */
|
||||||
|
export interface ScanReport {
|
||||||
|
cap: string;
|
||||||
|
self: string;
|
||||||
|
durationMs: number;
|
||||||
|
summary: { nodes: number; capable: number; configured: number; boundElsewhere: number; addable: number };
|
||||||
|
candidates: ScanCandidate[];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Lower-case, `[a-z0-9._-]` only — accepted by every consumer's name rules. */
|
||||||
|
export function suggestedName(instance: string): string {
|
||||||
|
const s = instance.trim().toLowerCase().replace(/[^a-z0-9._-]/g, '-');
|
||||||
|
return s || 'plugin';
|
||||||
|
}
|
||||||
|
|
||||||
|
const normUrl = (u: string) => u.trim().replace(/\/+$/, '');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Classify every resource matching `pattern` against the consumer's
|
||||||
|
* `(name, url)` list. Mirrors meta-feeder-sdk `beacon::classify`.
|
||||||
|
*/
|
||||||
|
export function classifyScan(
|
||||||
|
pattern: string,
|
||||||
|
self: string,
|
||||||
|
neighbors: MeshNeighbor[],
|
||||||
|
configured: Array<[string, string]>,
|
||||||
|
): ScanReport {
|
||||||
|
const summary = { nodes: neighbors.length, capable: 0, configured: 0, boundElsewhere: 0, addable: 0 };
|
||||||
|
const candidates: ScanCandidate[] = [];
|
||||||
|
for (const n of neighbors) {
|
||||||
|
for (const r of n.resources) {
|
||||||
|
if (!resourceMatches(r, pattern)) continue;
|
||||||
|
const http = resourceEndpoint(r, 'http');
|
||||||
|
if (!http) continue; // nothing a consumer could register
|
||||||
|
const url = normUrl(http);
|
||||||
|
summary.capable++;
|
||||||
|
const hit = configured.find(([, u]) => normUrl(u) === url);
|
||||||
|
let state: ScanState;
|
||||||
|
if (hit) { state = 'configured'; summary.configured++; }
|
||||||
|
else if (r.binds && r.binds !== self) { state = 'bound-elsewhere'; summary.boundElsewhere++; }
|
||||||
|
else { state = 'addable'; summary.addable++; }
|
||||||
|
candidates.push({
|
||||||
|
instance: n.instance,
|
||||||
|
name: n.name,
|
||||||
|
...(n.version ? { version: n.version } : {}),
|
||||||
|
resourceId: r.id,
|
||||||
|
caps: r.caps ?? [],
|
||||||
|
url,
|
||||||
|
...(r.binds ? { binds: r.binds } : {}),
|
||||||
|
state,
|
||||||
|
...(hit ? { configuredAs: hit[0] } : {}),
|
||||||
|
suggestedName: suggestedName(n.instance),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const rank: Record<ScanState, number> = { addable: 0, configured: 1, 'bound-elsewhere': 2 };
|
||||||
|
candidates.sort((a, b) => rank[a.state] - rank[b.state] || a.instance.localeCompare(b.instance));
|
||||||
|
return { cap: pattern, self, durationMs: 0, summary, candidates };
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does capability `cap` satisfy `pattern`? `*` matches everything; an `@N` on
|
* Does capability `cap` satisfy `pattern`? `*` matches everything; an `@N` on
|
||||||
* the pattern must equal the cap's contract (none ignores it); `x/*` matches
|
* the pattern must equal the cap's contract (none ignores it); `x/*` matches
|
||||||
@@ -333,6 +412,19 @@ export class MeshNode {
|
|||||||
return [...best.values()].sort((a, b) => a.name.localeCompare(b.name));
|
return [...best.values()].sort((a, b) => a.name.localeCompare(b.name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Scan card: probe everyone, wait `waitMs` for the replies, then
|
||||||
|
* classify what matches `pattern` against `configured` ([name, url]).
|
||||||
|
*/
|
||||||
|
async scan(pattern: string, configured: Array<[string, string]>, waitMs = 1500): Promise<ScanReport> {
|
||||||
|
const started = Date.now();
|
||||||
|
this.probe();
|
||||||
|
await new Promise((r) => setTimeout(r, waitMs));
|
||||||
|
const report = classifyScan(pattern, this.cfg.instance, this.getNeighbors(), configured);
|
||||||
|
report.durationMs = Date.now() - started;
|
||||||
|
return report;
|
||||||
|
}
|
||||||
|
|
||||||
/** This node as a row, so a UI can render itself without waiting. */
|
/** This node as a row, so a UI can render itself without waiting. */
|
||||||
self(): MeshNeighbor {
|
self(): MeshNeighbor {
|
||||||
const { status, resources } = this.payload();
|
const { status, resources } = this.payload();
|
||||||
@@ -557,6 +649,11 @@ export class MetaCoreLocator {
|
|||||||
return this.node.self();
|
return this.node.self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The Scan card — see {@link MeshNode.scan}. */
|
||||||
|
scan(pattern: string, configured: Array<[string, string]>, waitMs = 1500): Promise<ScanReport> {
|
||||||
|
return this.node.scan(pattern, configured, waitMs);
|
||||||
|
}
|
||||||
|
|
||||||
probe(want: string[] = []): void {
|
probe(want: string[] = []): void {
|
||||||
this.node.probe(want);
|
this.node.probe(want);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Logger } from 'tslog';
|
import { Logger } from 'tslog';
|
||||||
import { MetaCoreLocator, type MeshNeighbor } from '../discovery/meshdisco.js';
|
import { MetaCoreLocator, type MeshNeighbor, type ScanReport } from '../discovery/meshdisco.js';
|
||||||
import type { LeaderLockInfo } from './IKVClient.js';
|
import type { LeaderLockInfo } from './IKVClient.js';
|
||||||
|
|
||||||
const logger = new Logger({ name: 'LeaderClient' });
|
const logger = new Logger({ name: 'LeaderClient' });
|
||||||
@@ -268,6 +268,11 @@ export class LeaderClient {
|
|||||||
return this.locator.self();
|
return this.locator.self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Beacon v2 Scan card: probe, wait, classify `pattern` against `configured`. */
|
||||||
|
scan(pattern: string, configured: Array<[string, string]>, waitMs = 1500): Promise<ScanReport> {
|
||||||
|
return this.locator.scan(pattern, configured, waitMs);
|
||||||
|
}
|
||||||
|
|
||||||
close(): void {
|
close(): void {
|
||||||
this.onChangeCallbacks = [];
|
this.onChangeCallbacks = [];
|
||||||
void this.locator.stop();
|
void this.locator.stop();
|
||||||
|
|||||||
@@ -62,7 +62,8 @@ export function renamingRule(metadata: Partial<MediaMeta>, filepath?: string): s
|
|||||||
|
|
||||||
// Get title - try various fields
|
// Get title - try various fields
|
||||||
// The display name — never the `titles/*` name set (METADATA_KEYS.md §3).
|
// The display name — never the `titles/*` name set (METADATA_KEYS.md §3).
|
||||||
const title = metadata.title || metadata.originalTitle;
|
// `parsedTitle` is filename-parser's guess (claims model, D12): last resort.
|
||||||
|
const title = metadata.title || metadata.originalTitle || (metadata as { parsedTitle?: string }).parsedTitle;
|
||||||
if (!title) {
|
if (!title) {
|
||||||
if (metadata.fileType !== 'torrent') {
|
if (metadata.fileType !== 'torrent') {
|
||||||
// Don't warn for torrent files because they don't always have a title
|
// Don't warn for torrent files because they don't always have a title
|
||||||
|
|||||||
@@ -436,6 +436,7 @@ export class VirtualFileSystem implements VFSUpdateCallback {
|
|||||||
* Compute virtual path for a file using template rules
|
* Compute virtual path for a file using template rules
|
||||||
*/
|
*/
|
||||||
private computeVirtualPath(metadata: FileMetadata, sourcePath: string): string {
|
private computeVirtualPath(metadata: FileMetadata, sourcePath: string): string {
|
||||||
|
metadata = withParsedTitleFallback(metadata);
|
||||||
if (!this.rulesConfig) {
|
if (!this.rulesConfig) {
|
||||||
// Fallback to old behavior
|
// Fallback to old behavior
|
||||||
return this.metaDataToFolderStruct.generateSingleVirtualPath(sourcePath, metadata);
|
return this.metaDataToFolderStruct.generateSingleVirtualPath(sourcePath, metadata);
|
||||||
@@ -1105,6 +1106,7 @@ export class VirtualFileSystem implements VFSUpdateCallback {
|
|||||||
rules: RenamingRule[],
|
rules: RenamingRule[],
|
||||||
defaultRule?: RenamingRule
|
defaultRule?: RenamingRule
|
||||||
): string {
|
): string {
|
||||||
|
metadata = withParsedTitleFallback(metadata);
|
||||||
// Sort rules by priority (descending)
|
// Sort rules by priority (descending)
|
||||||
const sortedRules = [...rules]
|
const sortedRules = [...rules]
|
||||||
.filter(r => r.enabled)
|
.filter(r => r.enabled)
|
||||||
@@ -1304,3 +1306,15 @@ export class VirtualFileSystem implements VFSUpdateCallback {
|
|||||||
this.onFileComplete(hashId, metadata);
|
this.onFileComplete(hashId, metadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* filename-parser's guessed title lives under `parsedTitle` since the claims
|
||||||
|
* model (it no longer writes `originalTitle`, which tmdb also writes). The
|
||||||
|
* rules and templates fall back `title` → `originalTitle`; fill a missing
|
||||||
|
* `originalTitle` from `parsedTitle` on a copy so a file with only a parsed
|
||||||
|
* title still gets a path. The record itself is never changed.
|
||||||
|
*/
|
||||||
|
function withParsedTitleFallback<T extends { originalTitle?: unknown; parsedTitle?: unknown }>(metadata: T): T {
|
||||||
|
if (metadata.originalTitle || !metadata.parsedTitle) return metadata;
|
||||||
|
return { ...metadata, originalTitle: metadata.parsedTitle };
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user