Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.
TypeScript cloud-alternativecollaborationcollaborative-editingdropboxfile-serverfile-sharingfile-storagefile-syncfull-text-searchhomelabnextcloudon-premiseopen-sourceprivacy-firstprivate-cloudrealtimesecureself-hostedstorage-serverwebdav
fix(backend:spaces): invalidate spaces cache when space state changes
johaven0c95836d12b1
diff --git a/backend/src/applications/spaces/services/spaces-manager.service.ts b/backend/src/applications/spaces/services/spaces-manager.service.tsindex 111f1c7e..25644938 100644--- a/backend/src/applications/spaces/services/spaces-manager.service.ts+++ b/backend/src/applications/spaces/services/spaces-manager.service.ts@@ -236,6 +236,7 @@ export class SpacesManager {/* only managers of the space can update it */const space: SpaceProps = await this.userCanAccessSpace(user, spaceId, true)// check and update space info+ let mustInvalidateCache = falseconst spaceDiffProps: Partial<SpaceProps> = { modifiedAt: new Date() }const props: (keyof CreateOrUpdateSpaceDto)[] = ['name', 'description', 'enabled', 'storageQuota', 'storageIndexing']for (const prop of props) {@@ -253,6 +254,7 @@ export class SpacesManager {}} else if (prop === 'enabled') {spaceDiffProps.disabledAt = spaceDiffProps[prop] ? null : new Date()+ mustInvalidateCache = true}}}@@ -284,6 +286,9 @@ export class SpacesManager {const aliases: string[] = space.roots.map((r) => r.alias)const names: string[] = [...(await dirListFileNames(SpaceModel.getFilesPath(space.alias))), ...space.roots.map((r) => r.name)]await this.updateRoots(user, space, space.roots, createOrUpdateSpaceDto.roots, aliases, names)+ if (mustInvalidateCache) {+ void this.spacesQueries.clearCachePermissions(space.alias, undefined, [user.id])+ }if (rootOwnerIds.indexOf(user.id) > -1) {// current manager was removedreturn nulldiff --git a/backend/src/applications/spaces/services/spaces-queries.service.ts b/backend/src/applications/spaces/services/spaces-queries.service.tsindex 0b3e3461..fee71749 100644--- a/backend/src/applications/spaces/services/spaces-queries.service.ts+++ b/backend/src/applications/spaces/services/spaces-queries.service.ts@@ -712,6 +712,7 @@ export class SpacesQueries {rootAliases.forEach((rAlias: string) => patterns.push(this.cache.genSlugKey(...basePattern, rAlias)))} else {// clear cache on spaces list+ patterns.push(this.cache.genSlugKey(...[this.constructor.name, this.spaces.name, uid]))patterns.push(this.cache.genSlugKey(...[this.constructor.name, this.spaces.name, uid, '*']))// clear cache on spaces and rootspatterns.push(this.cache.genSlugKey(...basePattern), this.cache.genSlugKey(...basePattern, '*'))