(orgId: string, subscriptionId: string, usageCacheManager: UsageCacheManager)
| 151 | } |
| 152 | |
| 153 | export const checkStorage = async (orgId: string, subscriptionId: string, usageCacheManager: UsageCacheManager) => { |
| 154 | if (!usageCacheManager || !subscriptionId) return |
| 155 | |
| 156 | let currentStorageUsage = 0 |
| 157 | currentStorageUsage = (await usageCacheManager.get(`storage:${orgId}`)) || 0 |
| 158 | |
| 159 | const quotas = await usageCacheManager.getQuotas(subscriptionId) |
| 160 | const storageLimit = quotas[LICENSE_QUOTAS.STORAGE_LIMIT] |
| 161 | if (storageLimit === -1) return |
| 162 | |
| 163 | if (currentStorageUsage >= storageLimit) { |
| 164 | throw new InternalFlowiseError(StatusCodes.PAYMENT_REQUIRED, 'Storage limit exceeded') |
| 165 | } |
| 166 | |
| 167 | return { |
| 168 | usage: currentStorageUsage, |
| 169 | limit: storageLimit |
| 170 | } |
| 171 | } |
no test coverage detected