mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-13 16:16:46 +08:00
chore(server): watch storages config updates (#11367)
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
CallMetric,
|
||||
Config,
|
||||
type FileUpload,
|
||||
OnEvent,
|
||||
readBuffer,
|
||||
type StorageProvider,
|
||||
StorageProviderFactory,
|
||||
@@ -17,17 +18,27 @@ import { QuotaService } from '../../core/quota';
|
||||
|
||||
@Injectable()
|
||||
export class CopilotStorage {
|
||||
public readonly provider: StorageProvider;
|
||||
public provider!: StorageProvider;
|
||||
|
||||
constructor(
|
||||
private readonly config: Config,
|
||||
private readonly url: URLHelper,
|
||||
private readonly storageFactory: StorageProviderFactory,
|
||||
private readonly quota: QuotaService
|
||||
) {
|
||||
) {}
|
||||
|
||||
@OnEvent('config.init')
|
||||
async onConfigInit() {
|
||||
this.provider = this.storageFactory.create(this.config.copilot.storage);
|
||||
}
|
||||
|
||||
@OnEvent('config.changed')
|
||||
async onConfigChanged(event: Events['config.changed']) {
|
||||
if (event.updates?.copilot?.storage) {
|
||||
this.provider = this.storageFactory.create(this.config.copilot.storage);
|
||||
}
|
||||
}
|
||||
|
||||
@CallMetric('ai', 'blob_put')
|
||||
async put(
|
||||
userId: string,
|
||||
|
||||
Reference in New Issue
Block a user