2025-11-07 22:34:54 -08:00
|
|
|
/**
|
|
|
|
|
* WORM (Write Once Read Many) mode storage
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { StorageClient, StorageObject } from './storage';
|
|
|
|
|
|
|
|
|
|
export class WORMStorage extends StorageClient {
|
|
|
|
|
async upload(object: StorageObject): Promise<string> {
|
|
|
|
|
// WORM mode: prevent overwrites
|
|
|
|
|
const exists = await this.objectExists(object.key);
|
|
|
|
|
if (exists) {
|
|
|
|
|
throw new Error(`Object ${object.key} already exists in WORM storage`);
|
|
|
|
|
}
|
|
|
|
|
return super.upload(object);
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-10 19:43:02 -08:00
|
|
|
async delete(_key: string): Promise<void> {
|
2025-11-07 22:34:54 -08:00
|
|
|
throw new Error('Deletion not allowed in WORM mode');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|