feat(BillingService): implement fallback file path resolution for migrated workspaces
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 42s
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 42s
- Added logic to search for PDF templates in known upload directories when the base file name is provided. - Enhanced the robustness of file handling by checking multiple potential template directories for existing files. - Improved error handling by returning null for invalid base names, ensuring cleaner path resolution.
This commit is contained in:
@@ -51,6 +51,26 @@ class BillingService {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback fuer migrierte/verschobene Workspaces:
|
||||
// Datei ueber den Dateinamen in bekannten Upload-Ordnern suchen.
|
||||
const baseName = path.basename(rawPath);
|
||||
if (!baseName || baseName === '.' || baseName === '/') {
|
||||
return null;
|
||||
}
|
||||
const templateDirs = [
|
||||
path.resolve(process.cwd(), 'uploads', 'billing-templates'),
|
||||
path.resolve(process.cwd(), 'backend', 'uploads', 'billing-templates'),
|
||||
path.resolve(process.cwd(), '..', 'backend', 'uploads', 'billing-templates'),
|
||||
path.resolve(process.cwd(), '..', 'uploads', 'billing-templates')
|
||||
];
|
||||
for (const dir of templateDirs) {
|
||||
const candidate = path.join(dir, baseName);
|
||||
if (fs.existsSync(candidate)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user