Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

refactor(web): extract Google Drive quota cache invalidation

Richie McIlroy868d631cc24d
diff --git a/apps/web/lib/google-drive-storage-quota-cache.ts b/apps/web/lib/google-drive-storage-quota-cache.ts
new file mode 100644
index 000000000..a53000b5c
--- /dev/null
+++ b/apps/web/lib/google-drive-storage-quota-cache.ts
@@ -0,0 +1,25 @@
+import { db } from "@cap/database";
+import { storageIntegrations } from "@cap/database/schema";
+import { Storage } from "@cap/web-domain";
+import { and, eq } from "drizzle-orm";
+
+export const invalidateGoogleDriveStorageQuotaCache = async (
+ integrationId: string | null | undefined,
+) => {
+ if (!integrationId) return;
+ const storageIntegrationId = Storage.StorageIntegrationId.make(integrationId);
+
+ try {
+ await db()
+ .update(storageIntegrations)
+ .set({ googleDriveStorageQuotaCache: null })
+ .where(
+ and(
+ eq(storageIntegrations.id, storageIntegrationId),
+ eq(storageIntegrations.provider, "googleDrive"),
+ ),
+ );
+ } catch (error) {
+ console.error("Failed to invalidate Google Drive storage quota:", error);
+ }
+};