wip
This commit is contained in:
		| @@ -34,6 +34,8 @@ export type IMetadata = { | ||||
| 	src?: string; | ||||
| 	deletedAt?: Date; | ||||
| 	withoutChunks?: boolean; | ||||
| 	storage?: string; | ||||
| 	storageProps?: any; | ||||
| 	isSensitive?: boolean; | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -35,9 +35,11 @@ async function save(readable: stream.Readable, name: string, type: string, hash: | ||||
| 			await minio.putObject(config.drive.bucket, obj, readable); | ||||
|  | ||||
| 			Object.assign(metadata, { | ||||
| 				storage: 'object-storage', | ||||
| 				withoutChunks: true, | ||||
| 				obj: id, | ||||
| 				storage: 'object-storage', | ||||
| 				storageProps: { | ||||
| 					id: id | ||||
| 				}, | ||||
| 				url: `${ config.drive.config.secure ? 'https' : 'http' }://${ config.drive.config.endPoint }${ config.drive.config.port ? ':' + config.drive.config.port : '' }/${ config.drive.bucket }/${ obj }` | ||||
| 			}); | ||||
|  | ||||
|   | ||||
| @@ -1,7 +1,16 @@ | ||||
| import * as Minio from 'minio'; | ||||
| import DriveFile, { DriveFileChunk, IDriveFile } from '../../models/drive-file'; | ||||
| import DriveFileThumbnail, { DriveFileThumbnailChunk } from '../../models/drive-file-thumbnail'; | ||||
| import config from '../../config'; | ||||
|  | ||||
| export default async function(file: IDriveFile, isExpired = false) { | ||||
| 	if (file.metadata.withoutChunks) { | ||||
| 		if (file.metadata.storage == 'object-storage') { | ||||
| 			const minio = new Minio.Client(config.drive.config); | ||||
| 			const obj = `${config.drive.prefix}/${file.metadata.storageProps.id}`; | ||||
| 			await minio.removeObject(config.drive.bucket, obj); | ||||
| 		} | ||||
| 	} else { | ||||
| 		// チャンクをすべて削除 | ||||
| 		await DriveFileChunk.remove({ | ||||
| 			files_id: file._id | ||||
| @@ -27,4 +36,5 @@ export default async function(file: IDriveFile, isExpired = false) { | ||||
| 			await DriveFileThumbnail.remove({ _id: thumbnail._id }); | ||||
| 		} | ||||
| 		//#endregion | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 syuilo
					syuilo