This commit is contained in:
syuilo 2019-04-17 02:11:22 +09:00
parent b186504718
commit e265b538cc
No known key found for this signature in database
GPG Key ID: BDC4C49D06AB9D69
2 changed files with 8 additions and 1 deletions

View File

@ -129,12 +129,14 @@ export class Note {
}) })
public score: number; public score: number;
@Index()
@Column({ @Column({
...id(), ...id(),
array: true, default: '{}' array: true, default: '{}'
}) })
public fileIds: DriveFile['id'][]; public fileIds: DriveFile['id'][];
@Index()
@Column('varchar', { @Column('varchar', {
length: 256, array: true, default: '{}' length: 256, array: true, default: '{}'
}) })

View File

@ -2,7 +2,7 @@ import * as Minio from 'minio';
import config from '../../config'; import config from '../../config';
import { DriveFile } from '../../models/entities/drive-file'; import { DriveFile } from '../../models/entities/drive-file';
import { InternalStorage } from './internal-storage'; import { InternalStorage } from './internal-storage';
import { DriveFiles, Instances } from '../../models'; import { DriveFiles, Instances, Notes } from '../../models';
import { driveChart, perUserDriveChart, instanceChart } from '../chart'; import { driveChart, perUserDriveChart, instanceChart } from '../chart';
export default async function(file: DriveFile, isExpired = false) { export default async function(file: DriveFile, isExpired = false) {
@ -40,6 +40,11 @@ export default async function(file: DriveFile, isExpired = false) {
}); });
} else { } else {
DriveFiles.delete(file.id); DriveFiles.delete(file.id);
// TODO: トランザクション
Notes.createQueryBuilder('note').delete()
.andWhere(':id = ANY(note.fileIds)', { id: file.id })
.execute();
} }
// 統計を更新 // 統計を更新