Skip to content

Commit fa33fd5

Browse files
committed
fix: Solve an issue for what there was a double else block when initializing the storage manager
1 parent 8acb76e commit fa33fd5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/server/storage/StorageManager.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export class StorageManager {
1515
this.isS3 = false
1616
this.storageData = {}
1717
this.storageLoaded = false
18+
1819
// Throttle saves to avoid too many writes
1920
this.saveStorageData = throttle(() => this.persistStorageData(), 1000, { leading: true, trailing: true })
2021
}
@@ -24,13 +25,13 @@ export class StorageManager {
2425
*/
2526
async initialize() {
2627
const storageType = process.env.STORAGE_TYPE || StorageManager.STORAGE_TYPE.LOCAL;
27-
28+
2829
if (storageType === StorageManager.STORAGE_TYPE.S3) {
2930
// Validate required S3 configuration
3031
if (!process.env.S3_BUCKET_NAME) {
3132
throw new Error('S3_BUCKET_NAME is required when STORAGE_TYPE=s3')
3233
}
33-
34+
3435
// Initialize S3 storage
3536
this.isS3 = true
3637
const s3Config = {
@@ -41,6 +42,7 @@ export class StorageManager {
4142
storagePrefix: process.env.S3_STORAGE_PREFIX || 'storage/',
4243
cloudfrontUrl: process.env.CLOUDFRONT_URL,
4344
}
45+
4446
if (process.env.S3_ACCESS_KEY_ID && process.env.S3_SECRET_ACCESS_KEY) {
4547
s3Config.credentials = {
4648
accessKeyId: process.env.S3_ACCESS_KEY_ID,
@@ -62,8 +64,6 @@ export class StorageManager {
6264

6365
console.log('Initializing local file storage...')
6466
await this.storage.initialize()
65-
} else {
66-
throw new Error(`Unsupported storage type: ${storageType}. Supported types: 'local', 's3'`)
6767
}
6868

6969
// Initialize storage data
@@ -108,6 +108,7 @@ export class StorageManager {
108108
console.warn('Storage not yet loaded, cannot set value')
109109
return
110110
}
111+
111112
try {
112113
// Ensure value is serializable
113114
value = JSON.parse(JSON.stringify(value))
@@ -126,6 +127,7 @@ export class StorageManager {
126127
console.warn('Storage not yet loaded, cannot persist')
127128
return
128129
}
130+
129131
try {
130132
await this.storage.saveStorageData(this.storageData)
131133
// console.log('Storage data persisted successfully')

0 commit comments

Comments
 (0)