Fix bug nado
This commit is contained in:
parent
9c4e0a4ae6
commit
b3b82e7595
@ -58,8 +58,7 @@ drive:
|
||||
|
||||
# OR
|
||||
|
||||
# storage: 'object-storage'
|
||||
# service: 'minio'
|
||||
# storage: 'minio'
|
||||
# bucket:
|
||||
# prefix:
|
||||
# config:
|
||||
|
@ -51,9 +51,8 @@ export type Source = {
|
||||
|
||||
drive?: {
|
||||
storage: string;
|
||||
bucket: string;
|
||||
prefix: string;
|
||||
service?: string;
|
||||
bucket?: string;
|
||||
prefix?: string;
|
||||
config?: any;
|
||||
};
|
||||
|
||||
|
@ -21,9 +21,7 @@ import config from '../../config';
|
||||
const log = debug('misskey:drive:add-file');
|
||||
|
||||
async function save(readable: stream.Readable, name: string, type: string, hash: string, size: number, metadata: any): Promise<IDriveFile> {
|
||||
if (config.drive && config.drive.storage == 'object-storage') {
|
||||
if (config.drive.service == 'minio') {
|
||||
|
||||
if (config.drive && config.drive.storage == 'minio') {
|
||||
const minio = new Minio.Client(config.drive.config);
|
||||
const id = uuid.v4();
|
||||
const obj = `${config.drive.prefix}/${id}`;
|
||||
@ -31,7 +29,7 @@ async function save(readable: stream.Readable, name: string, type: string, hash:
|
||||
|
||||
Object.assign(metadata, {
|
||||
withoutChunks: true,
|
||||
storage: 'object-storage',
|
||||
storage: 'minio',
|
||||
storageProps: {
|
||||
id: id
|
||||
},
|
||||
@ -48,9 +46,6 @@ async function save(readable: stream.Readable, name: string, type: string, hash:
|
||||
});
|
||||
|
||||
return file;
|
||||
} else {
|
||||
throw 'unknown storage type';
|
||||
}
|
||||
} else {
|
||||
// Get MongoDB GridFS bucket
|
||||
const bucket = await getDriveFileBucket();
|
||||
|
@ -4,13 +4,12 @@ import DriveFileThumbnail, { DriveFileThumbnailChunk } from '../../models/drive-
|
||||
import config from '../../config';
|
||||
|
||||
export default async function(file: IDriveFile, isExpired = false) {
|
||||
if (file.metadata.withoutChunks) {
|
||||
if (file.metadata.storage == 'object-storage') {
|
||||
if (file.metadata.storage == 'minio') {
|
||||
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
|
||||
@ -37,4 +36,3 @@ export default async function(file: IDriveFile, isExpired = false) {
|
||||
}
|
||||
//#endregion
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user