0
0
This commit is contained in:
syuilo 2018-07-24 05:04:43 +09:00
parent 5458b10774
commit adc3c16ef3
5 changed files with 22 additions and 15 deletions

View File

@ -9,7 +9,7 @@ const q = {
'metadata._user.host': {
$ne: null
},
'metadata.isMetaOnly': false
'metadata.withoutChunks': false
};
async function main() {
@ -57,7 +57,7 @@ async function main() {
DriveFile.update({ _id: file._id }, {
$set: {
'metadata.isMetaOnly': true
'metadata.withoutChunks': true
}
})
]).then(async () => {

View File

@ -31,8 +31,9 @@ export type IMetadata = {
comment: string;
uri?: string;
url?: string;
src?: string;
deletedAt?: Date;
isMetaOnly?: boolean;
withoutChunks?: boolean;
isSensitive?: boolean;
};
@ -155,9 +156,9 @@ export const pack = (
_target = Object.assign(_target, _file.metadata);
_target.url = _file.metadata.url ? _file.metadata.url : `${config.drive_url}/${_target.id}/${encodeURIComponent(_target.name)}`;
_target.src = _file.metadata.url;
_target.url = _file.metadata.isMetaOnly ? _file.metadata.url : `${config.drive_url}/${_target.id}/${encodeURIComponent(_target.name)}`;
_target.isRemote = _file.metadata.isMetaOnly;
_target.isRemote = _file.metadata.withoutChunks;
if (_target.properties == null) _target.properties = {};

View File

@ -152,8 +152,8 @@ export async function createPerson(value: any, resolver?: Resolver): Promise<IUs
const avatarId = avatar ? avatar._id : null;
const bannerId = banner ? banner._id : null;
const avatarUrl = avatar && avatar.metadata.isMetaOnly ? avatar.metadata.url : null;
const bannerUrl = banner && banner.metadata.isMetaOnly ? banner.metadata.url : null;
const avatarUrl = avatar && avatar.metadata.url ? avatar.metadata.url : null;
const bannerUrl = banner && banner.metadata.url ? banner.metadata.url : null;
await User.update({ _id: user._id }, {
$set: {
@ -243,8 +243,8 @@ export async function updatePerson(value: string | IObject, resolver?: Resolver)
sharedInbox: person.sharedInbox,
avatarId: avatar ? avatar._id : null,
bannerId: banner ? banner._id : null,
avatarUrl: avatar && avatar.metadata.isMetaOnly ? avatar.metadata.url : null,
bannerUrl: banner && banner.metadata.isMetaOnly ? banner.metadata.url : null,
avatarUrl: avatar && avatar.metadata.url ? avatar.metadata.url : null,
bannerUrl: banner && banner.metadata.url ? banner.metadata.url : null,
description: htmlToMFM(person.summary),
followersCount,
followingCount,

View File

@ -37,7 +37,7 @@ export default async function(ctx: Koa.Context) {
return;
}
if (file.metadata.isMetaOnly) {
if (file.metadata.withoutChunks) {
ctx.status = 204;
return;
}

View File

@ -35,6 +35,8 @@ 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,
url: `${ config.drive.config.secure ? 'https' : 'http' }://${ config.drive.config.endPoint }${ config.drive.config.port ? ':' + config.drive.config.port : '' }/${ config.drive.bucket }/${ obj }`
});
@ -97,7 +99,7 @@ export default async function(
comment: string = null,
folderId: mongodb.ObjectID = null,
force: boolean = false,
metaOnly: boolean = false,
isLink: boolean = false,
url: string = null,
uri: string = null,
sensitive = false
@ -165,7 +167,7 @@ export default async function(
}
//#region Check drive usage
if (!metaOnly) {
if (!isLink) {
const usage = await DriveFile
.aggregate([{
$match: {
@ -277,19 +279,23 @@ export default async function(
folderId: folder !== null ? folder._id : null,
comment: comment,
properties: properties,
isMetaOnly: metaOnly,
withoutChunks: isLink,
isSensitive: sensitive
} as IMetadata;
if (url !== null) {
metadata.url = url;
metadata.src = url;
if (isLink) {
metadata.url = url;
}
}
if (uri !== null) {
metadata.uri = uri;
}
const driveFile = metaOnly
const driveFile = isLink
? await DriveFile.insert({
length: 0,
uploadDate: new Date(),