Files
wekan/models/lib/filesRoot.js
T
Lauri Ojansivu 31e569a18e Single-file WeKan for every platform with a Node.js bundle.
One executable per platform: that platform's published bundle repackaged
as a Node.js single executable application whose ZIP Node 26.11 mounts as
a virtual file system (useVfs + vfsArchive). Only FerretDB is copied out,
once and verified, to wekan-files/bin; native addons load from the VFS.

Everything WeKan writes is in wekan-files beside the executable, which
WRITABLE_PATH points at: attachments, avatars, db, bin, backup, logs,
versions. WeKan now treats a WRITABLE_PATH named wekan-files as the files
root (models/lib/filesRoot.js, shared by every place that derived it).

Started in a terminal it shows a menu: start, stop, status, version info
as Admin Panel / Version shows it, update to the newest release or change
to any other (checksum verified, backed up first, the old executable
kept), backup to wekan-files/backup/YYYY-MM-DD_HH-MM-SS, run at boot
(systemd, launchd, Task Scheduler, cron, Termux:Boot), log, settings.
Every entry is also a command. start runs the start-wekan.sh loop:
recovery, requested restore, FerretDB, recovery page, WeKan, restart.

Meteor's main.js chdir()s into the bundle, which a VFS cannot be, so the
server role keeps a virtual working directory. Node 26.11.1 breaks
fs.writev/readv while any VFS is mounted; they are rebuilt on fs.write
and fs.read.

single-file.yml builds every target in releases/single-file/targets.json
from its verified bundle (Macs on a Mac, to re-sign), starts it where a
runner exists with browser tests on amd64, and attaches what started.
Release All and Release All Missing call it.

Thanks to xet7 !
2026-10-13 21:08:09 +03:00

25 lines
1.1 KiB
JavaScript

'use strict';
// Is WRITABLE_PATH already the files root, or does WeKan append "files"?
//
// - Docker and dev (WRITABLE_PATH=/data or ..): WeKan appends /files, so
// attachments are at /data/files/attachments.
// - Snap (WRITABLE_PATH=$SNAP_COMMON/files): already the files root.
// - Single-file WeKan (releases/single-file): WRITABLE_PATH is the
// wekan-files directory beside the executable, and is already the files
// root, so attachments are at wekan-files/attachments and the database at
// wekan-files/db.
//
// "files" keeps its exact old rule (a separator before it, no trailing
// slash), so no existing install's files move. "wekan-files" is new: the
// last path segment must be exactly that, so /srv/my-files still gets
// /files appended, as it always did.
// No imports, so it works on the client and in release scripts too.
function isFilesRoot(base) {
const b = String(base || '');
if (b.endsWith('/files') || b.endsWith('\\files')) return true;
return b === 'wekan-files' || b.endsWith('/wekan-files') || b.endsWith('\\wekan-files');
}
module.exports = { isFilesRoot };