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 { randomUUID } from 'crypto';
|
||||||
import { promises as fs } from 'fs';
|
|
||||||
import path from 'path';
|
|
||||||
|
|
||||||
export interface BrandingConfig {
|
export interface BrandingConfig {
|
||||||
id: string;
|
id: string;
|
||||||
|
|
@ -27,22 +25,11 @@ export interface BrandingConfig {
|
||||||
|
|
||||||
class BrandingService {
|
class BrandingService {
|
||||||
private configs: Map<string, BrandingConfig> = new Map();
|
private configs: Map<string, BrandingConfig> = new Map();
|
||||||
private storagePath: string;
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.storagePath = path.join(process.cwd(), 'storage', 'branding');
|
|
||||||
this.ensureStorageDirectory();
|
|
||||||
this.loadDefaultBranding();
|
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() {
|
private loadDefaultBranding() {
|
||||||
// Create a default branding configuration
|
// Create a default branding configuration
|
||||||
const defaultBranding: BrandingConfig = {
|
const defaultBranding: BrandingConfig = {
|
||||||
|
|
@ -91,9 +78,6 @@ class BrandingService {
|
||||||
|
|
||||||
this.configs.set(id, branding);
|
this.configs.set(id, branding);
|
||||||
|
|
||||||
// Persist to disk
|
|
||||||
await this.persistBranding(id, branding);
|
|
||||||
|
|
||||||
return branding;
|
return branding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,31 +96,7 @@ class BrandingService {
|
||||||
throw new Error('Cannot delete default branding');
|
throw new Error('Cannot delete default branding');
|
||||||
}
|
}
|
||||||
|
|
||||||
const deleted = this.configs.delete(id);
|
return 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue