This commit is contained in:
syuilo 2018-07-21 19:17:15 +09:00
parent 049085fb7a
commit 297a7f541e
9 changed files with 17 additions and 13 deletions

View File

@ -41,6 +41,12 @@ redis:
port: 6379
pass: example-pass
# Drive capacity of a local user (MB)
localDriveCapacityMb: 256
# Drive capacity of a remote user (MB)
remoteDriveCapacityMb: 8
# If enabled:
# Server will not cache remote files (Using direct link instead).
# You can save your storage.

View File

@ -44,6 +44,9 @@ export default function load() {
mixin.status_url = `${mixin.scheme}://${mixin.host}/status`;
mixin.drive_url = `${mixin.scheme}://${mixin.host}/files`;
if (config.localDriveCapacityMb == null) config.localDriveCapacityMb = 256;
if (config.remoteDriveCapacityMb == null) config.remoteDriveCapacityMb = 8;
return Object.assign(config, mixin);
}

View File

@ -45,6 +45,8 @@ export type Source = {
secret_key: string;
};
localDriveCapacityMb: number;
remoteDriveCapacityMb: number;
preventCacheRemoteFiles: boolean;
/**

View File

@ -115,13 +115,6 @@ props:
ja: "ピン留めされた投稿のID"
en: "The ID of the pinned note of this user"
driveCapacity:
type: "number"
optional: false
desc:
ja: "ドライブの容量(bytes)"
en: "The capacity of drive of this user (bytes)"
host:
type: "string | null"
optional: false

View File

@ -43,7 +43,6 @@ type IUserBase = {
followingCount: number;
name?: string;
notesCount: number;
driveCapacity: number;
username: string;
usernameLower: string;
avatarId: mongo.ObjectID;
@ -418,7 +417,6 @@ export const pack = (
if (!meId || !meId.equals(_user.id) || !opts.detail) {
delete _user.avatarId;
delete _user.bannerId;
delete _user.driveCapacity;
delete _user.hasUnreadMessagingMessage;
delete _user.hasUnreadNotification;
}

View File

@ -107,7 +107,6 @@ export async function createPerson(value: any, resolver?: Resolver): Promise<IUs
followingCount,
notesCount,
name: person.name,
driveCapacity: 1024 * 1024 * 8, // 8MiB
isLocked: person.manuallyApprovesFollowers,
username: person.preferredUsername,
usernameLower: person.preferredUsername.toLowerCase(),

View File

@ -1,5 +1,6 @@
import DriveFile from '../../../models/drive-file';
import { ILocalUser } from '../../../models/user';
import config from '../../../config';
export const meta = {
desc: {
@ -38,7 +39,7 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
});
res({
capacity: user.driveCapacity,
capacity: 1024 * 1024 * config.localDriveCapacityMb,
usage: usage
});
});

View File

@ -72,7 +72,6 @@ export default async (ctx: Koa.Context) => {
followingCount: 0,
name: null,
notesCount: 0,
driveCapacity: 1024 * 1024 * 128, // 128MiB
username: username,
usernameLower: username.toLowerCase(),
host: null,

View File

@ -17,6 +17,7 @@ import { isLocalUser, IUser, IRemoteUser } from '../../models/user';
import { getDriveFileThumbnailBucket } from '../../models/drive-file-thumbnail';
import genThumbnail from '../../drive/gen-thumbnail';
import delFile from './delete-file';
import config from '../../config';
const gm = _gm.subClass({
imageMagick: true
@ -175,8 +176,10 @@ export default async function(
log(`drive usage is ${usage}`);
const driveCapacity = 1024 * 1024 * (isLocalUser(user) ? config.localDriveCapacityMb : config.remoteDriveCapacityMb);
// If usage limit exceeded
if (usage + size > user.driveCapacity) {
if (usage + size > driveCapacity) {
if (isLocalUser(user)) {
throw 'no-free-space';
} else {