Add full cross-platform path support
- Added automatic volume path translation in deployment (deploy.js) - Updated FileBrowser template to use /opt/ instead of hard-coded E:/ - Migrated self-updater.js to use centralized platformPaths module - Updated UI placeholders to use platform-neutral paths (/media/) - All paths now automatically adapt to Windows or Linux at runtime via process.platform detection
This commit is contained in:
@@ -16,18 +16,17 @@ const path = require('path');
|
||||
const crypto = require('crypto');
|
||||
const { execSync } = require('child_process');
|
||||
const zlib = require('zlib');
|
||||
|
||||
const isWindows = process.platform === 'win32';
|
||||
const platformPaths = require('./platform-paths');
|
||||
|
||||
const DEFAULTS = {
|
||||
CHECK_INTERVAL: 30 * 60 * 1000, // 30 minutes
|
||||
UPDATE_URL: 'https://get.dashcaddy.net/release',
|
||||
MIRROR_URL: 'https://get2.dashcaddy.net/release',
|
||||
UPDATES_DIR: isWindows ? 'C:/caddy/updates' : '/app/updates',
|
||||
UPDATES_DIR: platformPaths.isWindows ? path.join(platformPaths.caddyBase, 'updates') : '/app/updates',
|
||||
// API_SOURCE_DIR is the HOST path — written to trigger.json for the host-side updater
|
||||
API_SOURCE_DIR: isWindows ? 'C:/caddy/sites/dashcaddy-api' : '/etc/dashcaddy/sites/dashcaddy-api',
|
||||
API_SOURCE_DIR: path.join(platformPaths.caddySites, 'dashcaddy-api'),
|
||||
// FRONTEND_DIR is the container path — dashboard is volume-mounted at /app/dashboard
|
||||
FRONTEND_DIR: isWindows ? 'C:/caddy/sites/status' : '/app/dashboard',
|
||||
FRONTEND_DIR: platformPaths.isWindows ? path.join(platformPaths.caddySites, 'status') : '/app/dashboard',
|
||||
MAX_BACKUPS: 3,
|
||||
HEALTH_TIMEOUT: 60000,
|
||||
DOWNLOAD_TIMEOUT: 120000,
|
||||
@@ -44,7 +43,7 @@ class SelfUpdater extends EventEmitter {
|
||||
updatesDir: options.updatesDir || DEFAULTS.UPDATES_DIR,
|
||||
// hostUpdatesDir is the HOST path that maps to updatesDir inside the container.
|
||||
// Used when writing trigger.json so the host-side script can find staging files.
|
||||
hostUpdatesDir: options.hostUpdatesDir || (isWindows ? options.updatesDir || DEFAULTS.UPDATES_DIR : '/opt/dashcaddy/updates'),
|
||||
hostUpdatesDir: options.hostUpdatesDir || (platformPaths.isWindows ? options.updatesDir || DEFAULTS.UPDATES_DIR : '/opt/dashcaddy/updates'),
|
||||
apiSourceDir: options.apiSourceDir || DEFAULTS.API_SOURCE_DIR,
|
||||
frontendDir: options.frontendDir || DEFAULTS.FRONTEND_DIR,
|
||||
maxBackups: parseInt(options.maxBackups || DEFAULTS.MAX_BACKUPS, 10),
|
||||
|
||||
Reference in New Issue
Block a user