加载过程优化

This commit is contained in:
undefined committed 2020-06-17 13:15:12 +08:00
1 parent bc6426927f
commit 5db23edebb
8 files changed
+74 -58

No files matched your search

+3 -3
View File
@@ -57,8 +57,8 @@ async function get(_id, secret) {
const file = await coll.findOne({ _id });
if (typeof secret !== 'undefined') {
const timestamp = _timestamp();
if (!hash.check(file.secret, timestamp.toString(), secret)) {
if (!hash.check(file.secret, timestamp.toString() - 1, secret)) {
if (!(hash(file.secret, timestamp.toString()) === secret)) {
if (!(hash(file.secret, timestamp.toString() - 1) === secret)) {
throw new ForbiddenError();
}
}
@@ -72,7 +72,7 @@ function getMeta(_id) {
async function url(_id, name) {
const file = await coll.findOne({ _id });
const secret = hash.hash(file.secret, _timestamp().toString());
const secret = hash(file.secret, _timestamp().toString());
if (name) return `/fs/${_id}/${Buffer.from(name).toString('base64')}/${secret}`;
return `/fs/${_id}/${secret}`;
}