mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
server-ts: Convert blob.js
This commit is contained in:
parent
85af0a24ee
commit
cb14d4d8f9
@ -1,9 +1,9 @@
|
||||
const becca = require('../becca/becca.js');
|
||||
const NotFoundError = require('../errors/not_found_error.js');
|
||||
const protectedSessionService = require('./protected_session.js');
|
||||
const utils = require('./utils');
|
||||
import becca = require('../becca/becca.js');
|
||||
import NotFoundError = require('../errors/not_found_error');
|
||||
import protectedSessionService = require('./protected_session');
|
||||
import utils = require('./utils');
|
||||
|
||||
function getBlobPojo(entityName, entityId) {
|
||||
function getBlobPojo(entityName: string, entityId: string) {
|
||||
const entity = becca.getEntity(entityName, entityId);
|
||||
if (!entity) {
|
||||
throw new NotFoundError(`Entity ${entityName} '${entityId}' was not found.`);
|
||||
@ -25,7 +25,7 @@ function getBlobPojo(entityName, entityId) {
|
||||
return pojo;
|
||||
}
|
||||
|
||||
function processContent(content, isProtected, isStringContent) {
|
||||
function processContent(content: Buffer | string | null, isProtected: boolean, isStringContent: boolean) {
|
||||
if (isProtected) {
|
||||
if (protectedSessionService.isProtectedSessionAvailable()) {
|
||||
content = content === null ? null : protectedSessionService.decrypt(content);
|
||||
@ -48,7 +48,7 @@ function processContent(content, isProtected, isStringContent) {
|
||||
}
|
||||
}
|
||||
|
||||
function calculateContentHash({blobId, content}) {
|
||||
function calculateContentHash({blobId, content}: { blobId: string, content: Buffer }) {
|
||||
return utils.hash(`${blobId}|${content.toString()}`);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user