fix: thumbnail service updates

This commit is contained in:
KernelDeimos 2024-10-08 01:41:18 -04:00
parent ed0a83ca9d
commit c2a9506b48
2 changed files with 10 additions and 3 deletions

View File

@ -219,6 +219,7 @@ const install = async ({ services, app, useapi }) => {
services.registerService('counting', ConfigurableCountingService); services.registerService('counting', ConfigurableCountingService);
services.registerService('thumbnails', StrategizedService, { services.registerService('thumbnails', StrategizedService, {
strategy_key: 'engine', strategy_key: 'engine',
default_strategy: 'purejs',
strategies: { strategies: {
napi: [NAPIThumbnailService], napi: [NAPIThumbnailService],
purejs: [PureJSThumbnailService], purejs: [PureJSThumbnailService],

View File

@ -24,7 +24,7 @@ const UserParam = require("../../api/filesystem/UserParam");
const config = require("../../config"); const config = require("../../config");
const { chkperm, validate_fsentry_name } = require("../../helpers"); const { chkperm, validate_fsentry_name } = require("../../helpers");
const { TeePromise } = require("../../util/promise"); const { TeePromise } = require("../../util/promise");
const { pausing_tee, logging_stream, offset_write_stream } = require("../../util/streamutil"); const { pausing_tee, logging_stream, offset_write_stream, stream_to_the_void } = require("../../util/streamutil");
const { TYPE_DIRECTORY } = require("../FSNodeContext"); const { TYPE_DIRECTORY } = require("../FSNodeContext");
const { LLRead } = require("../ll_operations/ll_read"); const { LLRead } = require("../ll_operations/ll_read");
const { RootNodeSelector, NodePathSelector } = require("../node/selectors"); const { RootNodeSelector, NodePathSelector } = require("../node/selectors");
@ -299,7 +299,7 @@ class HLWrite extends HLFilesystemOperation {
this.checkpoint('before thumbnail'); this.checkpoint('before thumbnail');
let thumbnail_promise = new TeePromise(); let thumbnail_promise = new TeePromise();
let thumbnail; (async () => { (async () => {
const reason = await (async () => { const reason = await (async () => {
const { mime } = this.modules; const { mime } = this.modules;
const thumbnails = context.get('services').get('thumbnails'); const thumbnails = context.get('services').get('thumbnails');
@ -324,7 +324,13 @@ class HLWrite extends HLFilesystemOperation {
return { ...values.file, stream: thumbnail_stream }; return { ...values.file, stream: thumbnail_stream };
})(); })();
let thumbnail;
try {
thumbnail = await thumbnails.thumbify(thumb_file); thumbnail = await thumbnails.thumbify(thumb_file);
} catch (e) {
stream_to_the_void(thumb_file.stream);
return 'thumbnail error: ' + e.message;
}
thumbnail_promise.resolve(thumbnail); thumbnail_promise.resolve(thumbnail);
})(); })();
if ( reason ) { if ( reason ) {