Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Commit

Permalink
remove cache on get file list
Browse files Browse the repository at this point in the history
  • Loading branch information
mgilangjanuar committed Jan 14, 2022
1 parent 3d6303c commit bcca1da
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions server/src/api/v1/Files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import moment from 'moment'
import multer from 'multer'
import { Files as Model } from '../../model/entities/Files'
import { Usages } from '../../model/entities/Usages'
import { Redis } from '../../service/Cache'
import { TG_CREDS } from '../../utils/Constant'
import { buildSort, buildWhereQuery } from '../../utils/FilterQuery'
import { Endpoint } from '../base/Endpoint'
Expand All @@ -28,7 +27,7 @@ export class Files {
throw { status: 404, body: { error: 'Parent not found' } }
}

const [files, length] = await Redis.connect().getFromCacheFirst(`files:${req.user?.id || 'null'}:${JSON.stringify(req.query || {})}`, async () => await Model.createQueryBuilder('files')
const [files, length] = await Model.createQueryBuilder('files')
.where(shared && (parent?.sharing_options?.includes(req.user?.username) || parent?.sharing_options?.includes('*'))
? 'true' : shared
? ':user = any(files.sharing_options) and (files.parent_id is null or parent.sharing_options is null or cardinality(parent.sharing_options) = 0 or not :user = any(parent.sharing_options))'
Expand All @@ -39,7 +38,7 @@ export class Files {
.skip(Number(offset) || 0)
.take(Number(limit) || 10)
.orderBy(buildSort(sort as string, 'files.'))
.getManyAndCount(), 1)
.getManyAndCount()
return res.send({ files, length })
}

Expand Down

0 comments on commit bcca1da

Please sign in to comment.