Update delete-file.ts
This commit is contained in:
parent
0709cac97f
commit
33ad190524
1 changed files with 8 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
|||
import * as Minio from 'minio';
|
||||
import DriveFile, { DriveFileChunk, IDriveFile } from '../../models/drive-file';
|
||||
import DriveFile, { DriveFileChunk, IDriveFile, getDriveFileBucket } from '../../models/drive-file';
|
||||
import DriveFileThumbnail, { DriveFileThumbnailChunk } from '../../models/drive-file-thumbnail';
|
||||
import config from '../../config';
|
||||
import driveChart from '../../services/chart/drive';
|
||||
|
@ -7,7 +7,7 @@ import perUserDriveChart from '../../services/chart/per-user-drive';
|
|||
import instanceChart from '../../services/chart/instance';
|
||||
import DriveFileWebpublic, { DriveFileWebpublicChunk } from '../../models/drive-file-webpublic';
|
||||
import Instance from '../../models/instance';
|
||||
import { isRemoteUser } from '../../models/user';
|
||||
import User, { isRemoteUser } from '../../models/user';
|
||||
|
||||
export default async function(file: IDriveFile, isExpired = false) {
|
||||
if (file.metadata.storage == 'minio') {
|
||||
|
@ -56,6 +56,12 @@ export default async function(file: IDriveFile, isExpired = false) {
|
|||
$set: set
|
||||
});
|
||||
|
||||
await Promise.all(['avatarId', 'bannerId', 'wallpaperId']
|
||||
.map(target => User.find({ [target]: file._id })
|
||||
.then(x => Promise.all(x.map(x => User.update({ _id: x._id }, {
|
||||
$unset: { [target]: file._id }
|
||||
}))))));
|
||||
|
||||
//#region サムネイルもあれば削除
|
||||
const thumbnail = await DriveFileThumbnail.findOne({
|
||||
'metadata.originalId': file._id
|
||||
|
|
Loading…
Reference in a new issue