mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: support pathStyle setting
This commit is contained in:
1 parent
ed8ae6ba69
commit
57850fd53e
12 files changed
+58
-63
No files matched your search
@@ -32,10 +32,9 @@ class BlackListModel {
|
||||
}
|
||||
}
|
||||
|
||||
async function ensureIndexes() {
|
||||
return await coll.createIndex('expireAt', { expireAfterSeconds: 0 });
|
||||
}
|
||||
|
||||
bus.once('app/started', ensureIndexes);
|
||||
bus.once('app/started', () => db.ensureIndexes(
|
||||
coll,
|
||||
{ key: { expireAt: -1 }, name: 'expire', expireAfterSeconds: 0 },
|
||||
));
|
||||
export default BlackListModel;
|
||||
global.Hydro.model.blacklist = BlackListModel;
|
||||
@@ -65,13 +65,10 @@ class MessageModel {
|
||||
}
|
||||
}
|
||||
|
||||
function ensureIndexes() {
|
||||
return Promise.all([
|
||||
coll.createIndex({ to: 1, _id: -1 }),
|
||||
coll.createIndex({ from: 1, _id: -1 }),
|
||||
]);
|
||||
}
|
||||
|
||||
bus.once('app/started', ensureIndexes);
|
||||
bus.once('app/started', () => db.ensureIndexes(
|
||||
coll,
|
||||
{ key: { to: 1, _id: -1 }, name: 'to' },
|
||||
{ key: { from: 1, _id: -1 }, name: 'from' },
|
||||
));
|
||||
export default MessageModel;
|
||||
global.Hydro.model.message = MessageModel;
|
||||
@@ -20,12 +20,9 @@ export async function inc(op: string, ident: string, periodSecs: number, maxOper
|
||||
}
|
||||
}
|
||||
|
||||
function ensureIndexes() {
|
||||
return Promise.all([
|
||||
coll.createIndex('expireAt', { expireAfterSeconds: 0 }),
|
||||
coll.createIndex({ op: 1, ident: 1, expireAt: 1 }, { unique: true }),
|
||||
]);
|
||||
}
|
||||
|
||||
bus.once('app/started', ensureIndexes);
|
||||
bus.once('app/started', () => db.ensureIndexes(
|
||||
coll,
|
||||
{ key: { expireAt: -1 }, name: 'expire', expireAfterSeconds: 0 },
|
||||
{ key: { op: 1, ident: 1, expireAt: 1 }, name: 'unique', unique: true },
|
||||
));
|
||||
global.Hydro.model.opcount = { inc };
|
||||
@@ -234,14 +234,12 @@ bus.on('domain/delete', (domainId) => Promise.all([
|
||||
RecordModel.coll.updateMany({ pdomain: domainId }, { $set: { docId: -1 } }),
|
||||
]));
|
||||
|
||||
bus.on('app/started', () => {
|
||||
return db.ensureIndexes(
|
||||
RecordModel.coll,
|
||||
{ key: { domainId: 1, 'contest.tid': 1, hidden: 1, _id: -1 }, name: 'basic' },
|
||||
{ key: { domainId: 1, 'contest.tid': 1, hidden: 1, uid: 1, _id: -1 }, name: 'withUser' },
|
||||
{ key: { domainId: 1, 'contest.tid': 1, hidden: 1, pid: 1, _id: -1 }, name: 'withProblem' },
|
||||
);
|
||||
});
|
||||
bus.once('app/started', () => db.ensureIndexes(
|
||||
RecordModel.coll,
|
||||
{ key: { domainId: 1, 'contest.tid': 1, hidden: 1, _id: -1 }, name: 'basic' },
|
||||
{ key: { domainId: 1, 'contest.tid': 1, hidden: 1, uid: 1, _id: -1 }, name: 'withUser' },
|
||||
{ key: { domainId: 1, 'contest.tid': 1, hidden: 1, pid: 1, _id: -1 }, name: 'withProblem' },
|
||||
));
|
||||
|
||||
export default RecordModel;
|
||||
global.Hydro.model.record = RecordModel;
|
||||
@@ -163,6 +163,7 @@ SystemSetting(
|
||||
Setting('setting_file', 'file.secretKey', null, 'password', 'file.secretKey', 'Storage engine secret', FLAG_SECRET),
|
||||
Setting('setting_file', 'file.bucket', 'hydro', 'text', 'file.bucket', 'Storage engine bucket'),
|
||||
Setting('setting_file', 'file.region', 'us-east-1', 'text', 'file.region', 'Storage engine region'),
|
||||
Setting('setting_file', 'file.pathStyle', true, 'boolean', 'file.pathStyle', 'pathStyle endpoint'),
|
||||
Setting('setting_file', 'file.endPointForUser', '/fs/', 'text', 'file.endPointForUser', 'EndPoint for user'),
|
||||
Setting('setting_file', 'file.endPointForJudge', '/fs/', 'text', 'file.endPointForJudge', 'EndPoint for judge'),
|
||||
Setting('setting_smtp', 'smtp.user', null, 'text', 'smtp.user', 'SMTP Username'),
|
||||
|
||||
@@ -92,13 +92,10 @@ class TokenModel {
|
||||
}
|
||||
}
|
||||
|
||||
function ensureIndexes() {
|
||||
return Promise.all([
|
||||
TokenModel.coll.createIndex({ uid: 1, tokenType: 1, updateAt: -1 }, { sparse: true }),
|
||||
TokenModel.coll.createIndex('expireAt', { expireAfterSeconds: 0 }),
|
||||
]);
|
||||
}
|
||||
|
||||
bus.once('app/started', ensureIndexes);
|
||||
bus.once('app/started', () => db.ensureIndexes(
|
||||
TokenModel.coll,
|
||||
{ key: { uid: 1, tokenType: 1, updateAt: -1 }, name: 'basic', sparse: true },
|
||||
{ key: { expireAt: -1 }, name: 'expire', expireAfterSeconds: 0 },
|
||||
));
|
||||
export default TokenModel;
|
||||
global.Hydro.model.token = TokenModel;
|
||||
@@ -3,8 +3,9 @@ import LRU from 'lru-cache';
|
||||
import { Collection } from 'mongodb';
|
||||
import { LoginError, UserAlreadyExistError, UserNotFoundError } from '../error';
|
||||
import {
|
||||
FileInfo,
|
||||
Udict, Udoc, User as _User } from '../interface';
|
||||
FileInfo, Udict, Udoc,
|
||||
User as _User,
|
||||
} from '../interface';
|
||||
import pwhash from '../lib/hash.hydro';
|
||||
import { Logger } from '../logger';
|
||||
import * as bus from '../service/bus';
|
||||
@@ -338,13 +339,10 @@ class UserModel {
|
||||
}
|
||||
}
|
||||
|
||||
function ensureIndexes() {
|
||||
return Promise.all([
|
||||
coll.createIndex('unameLower', { unique: true }),
|
||||
coll.createIndex('mailLower', { sparse: true }),
|
||||
]);
|
||||
}
|
||||
|
||||
bus.once('app/started', ensureIndexes);
|
||||
bus.once('app/started', () => db.ensureIndexes(
|
||||
coll,
|
||||
{ key: { unameLower: 1 }, name: 'uname', unique: true },
|
||||
{ key: { mailLower: 1 }, name: 'mail', unique: true },
|
||||
));
|
||||
export default UserModel;
|
||||
global.Hydro.model.user = UserModel;
|
||||
Reference in new issue
Block a user