Fix branding service to use in-memory storage
Remove file system operations that were causing permission errors in the Docker container. Branding configs now stored in memory only. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
d8f384d44a
commit
9fe6823508
1 changed files with 1 additions and 41 deletions
|
|
@ -4,8 +4,6 @@
|
|||
*/
|
||||
|
||||
import { randomUUID } from 'crypto';
|
||||
import { promises as fs } from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
export interface BrandingConfig {
|
||||
id: string;
|
||||
|
|
@ -27,22 +25,11 @@ export interface BrandingConfig {
|
|||
|
||||
class BrandingService {
|
||||
private configs: Map<string, BrandingConfig> = new Map();
|
||||
private storagePath: string;
|
||||
|
||||
constructor() {
|
||||
this.storagePath = path.join(process.cwd(), 'storage', 'branding');
|
||||
this.ensureStorageDirectory();
|
||||
this.loadDefaultBranding();
|
||||
}
|
||||
|
||||
private async ensureStorageDirectory() {
|
||||
try {
|
||||
await fs.mkdir(this.storagePath, { recursive: true });
|
||||
} catch (error) {
|
||||
console.warn('Could not create branding storage directory:', error);
|
||||
}
|
||||
}
|
||||
|
||||
private loadDefaultBranding() {
|
||||
// Create a default branding configuration
|
||||
const defaultBranding: BrandingConfig = {
|
||||
|
|
@ -91,9 +78,6 @@ class BrandingService {
|
|||
|
||||
this.configs.set(id, branding);
|
||||
|
||||
// Persist to disk
|
||||
await this.persistBranding(id, branding);
|
||||
|
||||
return branding;
|
||||
}
|
||||
|
||||
|
|
@ -112,31 +96,7 @@ class BrandingService {
|
|||
throw new Error('Cannot delete default branding');
|
||||
}
|
||||
|
||||
const deleted = this.configs.delete(id);
|
||||
|
||||
if (deleted) {
|
||||
// Remove from disk
|
||||
try {
|
||||
const filePath = path.join(this.storagePath, `${id}.json`);
|
||||
await fs.unlink(filePath);
|
||||
} catch (error) {
|
||||
console.warn(`Could not delete branding file for ${id}:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
return deleted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist branding configuration to disk
|
||||
*/
|
||||
private async persistBranding(id: string, branding: BrandingConfig) {
|
||||
try {
|
||||
const filePath = path.join(this.storagePath, `${id}.json`);
|
||||
await fs.writeFile(filePath, JSON.stringify(branding, null, 2));
|
||||
} catch (error) {
|
||||
console.error(`Failed to persist branding ${id}:`, error);
|
||||
}
|
||||
return this.configs.delete(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue