Route all file I/O through storage layer (S3 or disk)
- filter.mjs: loadProfile now async, uses loadJSON - telegram_answers.mjs: answers read/write through storage layer - status.mjs: uses initQueue + loadQueue for S3 support - setup.mjs: await all loadConfig calls - storage.mjs: more robust getS3Key using URL parsing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -28,11 +28,11 @@ export function storageType() {
|
||||
|
||||
function getS3Key(filePath) {
|
||||
// Extract relative path from project root (e.g. config/foo.json or data/bar.json)
|
||||
const projectRoot = dirname(dirname(import.meta.url.replace('file://', '')));
|
||||
const storageUrl = new URL(import.meta.url);
|
||||
const projectRoot = dirname(dirname(storageUrl.pathname));
|
||||
const abs = filePath.startsWith('/') ? filePath : join(projectRoot, filePath);
|
||||
if (abs.startsWith(projectRoot)) {
|
||||
const rel = abs.slice(projectRoot.length + 1);
|
||||
return rel;
|
||||
if (abs.startsWith(projectRoot + '/')) {
|
||||
return abs.slice(projectRoot.length + 1);
|
||||
}
|
||||
// Fallback: use last two path segments (e.g. data/jobs_queue.json)
|
||||
const parts = filePath.split('/');
|
||||
|
||||
Reference in New Issue
Block a user