mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-12-23 18:13:10 +02:00
This commit is contained in:
parent
049085fb7a
commit
297a7f541e
9 changed files with 17 additions and 13 deletions
|
@ -41,6 +41,12 @@ redis:
|
||||||
port: 6379
|
port: 6379
|
||||||
pass: example-pass
|
pass: example-pass
|
||||||
|
|
||||||
|
# Drive capacity of a local user (MB)
|
||||||
|
localDriveCapacityMb: 256
|
||||||
|
|
||||||
|
# Drive capacity of a remote user (MB)
|
||||||
|
remoteDriveCapacityMb: 8
|
||||||
|
|
||||||
# If enabled:
|
# If enabled:
|
||||||
# Server will not cache remote files (Using direct link instead).
|
# Server will not cache remote files (Using direct link instead).
|
||||||
# You can save your storage.
|
# You can save your storage.
|
||||||
|
|
|
@ -44,6 +44,9 @@ export default function load() {
|
||||||
mixin.status_url = `${mixin.scheme}://${mixin.host}/status`;
|
mixin.status_url = `${mixin.scheme}://${mixin.host}/status`;
|
||||||
mixin.drive_url = `${mixin.scheme}://${mixin.host}/files`;
|
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);
|
return Object.assign(config, mixin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,8 @@ export type Source = {
|
||||||
secret_key: string;
|
secret_key: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
localDriveCapacityMb: number;
|
||||||
|
remoteDriveCapacityMb: number;
|
||||||
preventCacheRemoteFiles: boolean;
|
preventCacheRemoteFiles: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -115,13 +115,6 @@ props:
|
||||||
ja: "ピン留めされた投稿のID"
|
ja: "ピン留めされた投稿のID"
|
||||||
en: "The ID of the pinned note of this user"
|
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:
|
host:
|
||||||
type: "string | null"
|
type: "string | null"
|
||||||
optional: false
|
optional: false
|
||||||
|
|
|
@ -43,7 +43,6 @@ type IUserBase = {
|
||||||
followingCount: number;
|
followingCount: number;
|
||||||
name?: string;
|
name?: string;
|
||||||
notesCount: number;
|
notesCount: number;
|
||||||
driveCapacity: number;
|
|
||||||
username: string;
|
username: string;
|
||||||
usernameLower: string;
|
usernameLower: string;
|
||||||
avatarId: mongo.ObjectID;
|
avatarId: mongo.ObjectID;
|
||||||
|
@ -418,7 +417,6 @@ export const pack = (
|
||||||
if (!meId || !meId.equals(_user.id) || !opts.detail) {
|
if (!meId || !meId.equals(_user.id) || !opts.detail) {
|
||||||
delete _user.avatarId;
|
delete _user.avatarId;
|
||||||
delete _user.bannerId;
|
delete _user.bannerId;
|
||||||
delete _user.driveCapacity;
|
|
||||||
delete _user.hasUnreadMessagingMessage;
|
delete _user.hasUnreadMessagingMessage;
|
||||||
delete _user.hasUnreadNotification;
|
delete _user.hasUnreadNotification;
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,6 @@ export async function createPerson(value: any, resolver?: Resolver): Promise<IUs
|
||||||
followingCount,
|
followingCount,
|
||||||
notesCount,
|
notesCount,
|
||||||
name: person.name,
|
name: person.name,
|
||||||
driveCapacity: 1024 * 1024 * 8, // 8MiB
|
|
||||||
isLocked: person.manuallyApprovesFollowers,
|
isLocked: person.manuallyApprovesFollowers,
|
||||||
username: person.preferredUsername,
|
username: person.preferredUsername,
|
||||||
usernameLower: person.preferredUsername.toLowerCase(),
|
usernameLower: person.preferredUsername.toLowerCase(),
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import DriveFile from '../../../models/drive-file';
|
import DriveFile from '../../../models/drive-file';
|
||||||
import { ILocalUser } from '../../../models/user';
|
import { ILocalUser } from '../../../models/user';
|
||||||
|
import config from '../../../config';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
|
@ -38,7 +39,7 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
|
||||||
});
|
});
|
||||||
|
|
||||||
res({
|
res({
|
||||||
capacity: user.driveCapacity,
|
capacity: 1024 * 1024 * config.localDriveCapacityMb,
|
||||||
usage: usage
|
usage: usage
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -72,7 +72,6 @@ export default async (ctx: Koa.Context) => {
|
||||||
followingCount: 0,
|
followingCount: 0,
|
||||||
name: null,
|
name: null,
|
||||||
notesCount: 0,
|
notesCount: 0,
|
||||||
driveCapacity: 1024 * 1024 * 128, // 128MiB
|
|
||||||
username: username,
|
username: username,
|
||||||
usernameLower: username.toLowerCase(),
|
usernameLower: username.toLowerCase(),
|
||||||
host: null,
|
host: null,
|
||||||
|
|
|
@ -17,6 +17,7 @@ import { isLocalUser, IUser, IRemoteUser } from '../../models/user';
|
||||||
import { getDriveFileThumbnailBucket } from '../../models/drive-file-thumbnail';
|
import { getDriveFileThumbnailBucket } from '../../models/drive-file-thumbnail';
|
||||||
import genThumbnail from '../../drive/gen-thumbnail';
|
import genThumbnail from '../../drive/gen-thumbnail';
|
||||||
import delFile from './delete-file';
|
import delFile from './delete-file';
|
||||||
|
import config from '../../config';
|
||||||
|
|
||||||
const gm = _gm.subClass({
|
const gm = _gm.subClass({
|
||||||
imageMagick: true
|
imageMagick: true
|
||||||
|
@ -175,8 +176,10 @@ export default async function(
|
||||||
|
|
||||||
log(`drive usage is ${usage}`);
|
log(`drive usage is ${usage}`);
|
||||||
|
|
||||||
|
const driveCapacity = 1024 * 1024 * (isLocalUser(user) ? config.localDriveCapacityMb : config.remoteDriveCapacityMb);
|
||||||
|
|
||||||
// If usage limit exceeded
|
// If usage limit exceeded
|
||||||
if (usage + size > user.driveCapacity) {
|
if (usage + size > driveCapacity) {
|
||||||
if (isLocalUser(user)) {
|
if (isLocalUser(user)) {
|
||||||
throw 'no-free-space';
|
throw 'no-free-space';
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue