Remove ssb.messageContentGet. It's easy to do this with ssb.sqlAsync, and this wasn't being used productively. Three uses of DB on the main thread remaining.

This commit is contained in:
2024-06-16 16:02:39 -04:00
parent 3eab5a5f70
commit dbe24494d9
2 changed files with 7 additions and 42 deletions

View File

@ -749,7 +749,7 @@ async function getProcessBlob(blobId, key, options) {
};
process.task.setImports(imports);
process.task.activate();
let source = await getBlobOrContent(blobId);
let source = await ssb.blobGet(blobId);
let appSourceName = blobId;
let appSource = utf8Decode(source);
try {
@ -757,7 +757,7 @@ async function getProcessBlob(blobId, key, options) {
if (appObject.type == 'tildefriends-app') {
appSourceName = options?.script ?? 'app.js';
let id = appObject.files[appSourceName];
let blob = await getBlobOrContent(id);
let blob = await ssb.blobGet(id);
appSource = utf8Decode(blob);
await process.task.loadFile([
'/tfrpc.js',
@ -767,7 +767,7 @@ async function getProcessBlob(blobId, key, options) {
Object.keys(appObject.files).map(async function (f) {
await process.task.loadFile([
f,
await getBlobOrContent(appObject.files[f]),
await ssb.blobGet(appObject.files[f]),
]);
})
);
@ -851,21 +851,6 @@ function sendData(response, data, type, headers, status_code) {
}
}
/**
* TODOC
* @param {*} id
* @returns
*/
async function getBlobOrContent(id) {
if (!id) {
return;
} else if (id.startsWith('&')) {
return ssb.blobGet(id);
} else if (id.startsWith('%')) {
return ssb.messageContentGet(id);
}
}
let g_handler_index = 0;
/**
@ -993,7 +978,7 @@ async function blobHandler(request, response, blobId, uri) {
response.writeHead(304, headers);
response.end();
} else {
data = await getBlobOrContent(id);
data = await ssb.blobGet(id);
if (match[3]) {
let appObject = JSON.parse(data);
data = appObject.files[match[3]];
@ -1025,7 +1010,7 @@ async function blobHandler(request, response, blobId, uri) {
response.writeHead(304, headers);
response.end();
} else {
data = await getBlobOrContent(blobId);
data = await ssb.blobGet(blobId);
sendData(
response,
data,
@ -1141,7 +1126,7 @@ async function blobHandler(request, response, blobId, uri) {
app_id = await db.get('path:' + match[2]);
}
let app_object = JSON.parse(utf8Decode(await getBlobOrContent(app_id)));
let app_object = JSON.parse(utf8Decode(await ssb.blobGet(app_id)));
id = app_object?.files[uri.substring(1)];
if (!id && app_object?.files['handler.js']) {
let answer;
@ -1197,7 +1182,7 @@ async function blobHandler(request, response, blobId, uri) {
'Access-Control-Allow-Origin': '*',
'Content-Security-Policy': k_content_security_policy,
};
data = await getBlobOrContent(id);
data = await ssb.blobGet(id);
let type =
httpd.mime_type_from_extension(uri) ||
httpd.mime_type_from_magic_bytes(data);