Skip to content

Commit

Permalink
Fix remote drive expire
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed May 29, 2021
1 parent f9035eb commit f805a9a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/models/repositories/drive-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export class DriveFileRepository extends Repository<DriveFile> {
const { sum } = await this
.createQueryBuilder('file')
.where('file.userId = :id', { id: id })
.andWhere('file.isLink = FALSE')
.select('SUM(file.size)', 'sum')
.getRawOne();

Expand All @@ -69,6 +70,7 @@ export class DriveFileRepository extends Repository<DriveFile> {
const { sum } = await this
.createQueryBuilder('file')
.where('file.userHost = :host', { host: toPuny(host) })
.andWhere('file.isLink = FALSE')
.select('SUM(file.size)', 'sum')
.getRawOne();

Expand All @@ -79,6 +81,7 @@ export class DriveFileRepository extends Repository<DriveFile> {
const { sum } = await this
.createQueryBuilder('file')
.where('file.userHost IS NULL')
.andWhere('file.isLink = FALSE')
.select('SUM(file.size)', 'sum')
.getRawOne();

Expand All @@ -89,6 +92,7 @@ export class DriveFileRepository extends Repository<DriveFile> {
const { sum } = await this
.createQueryBuilder('file')
.where('file.userHost IS NOT NULL')
.andWhere('file.isLink = FALSE')
.select('SUM(file.size)', 'sum')
.getRawOne();

Expand Down
3 changes: 2 additions & 1 deletion src/services/drive/add-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ async function upload(key: string, stream: fs.ReadStream | Buffer, type: string,

async function deleteOldFile(user: IRemoteUser) {
const q = DriveFiles.createQueryBuilder('file')
.where('file.userId = :userId', { userId: user.id });
.where('file.userId = :userId', { userId: user.id })
.andWhere('file.isLink = FALSE');

if (user.avatarId) {
q.andWhere('file.id != :avatarId', { avatarId: user.avatarId });
Expand Down
2 changes: 1 addition & 1 deletion src/services/drive/delete-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function postProcess(file: DriveFile, isExpired = false) {
url: file.uri,
thumbnailUrl: null,
webpublicUrl: null,
size: 0,
storedInternal: false,
// ローカルプロキシ用
accessKey: uuid(),
thumbnailAccessKey: 'thumbnail-' + uuid(),
Expand Down

0 comments on commit f805a9a

Please sign in to comment.