summaryrefslogtreecommitdiff
path: root/src/services/drive
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2019-06-13 22:59:15 +0900
committersyuilo <syuilotan@yahoo.co.jp>2019-06-13 22:59:15 +0900
commite9dc54c4d9e61e0aefa1c106a51ddf27febc65a7 (patch)
treef380f42a4fd0e17954670fb07b40572545879f2e /src/services/drive
parentMake url preview log warn (diff)
downloadmisskey-e9dc54c4d9e61e0aefa1c106a51ddf27febc65a7.tar.gz
misskey-e9dc54c4d9e61e0aefa1c106a51ddf27febc65a7.tar.bz2
misskey-e9dc54c4d9e61e0aefa1c106a51ddf27febc65a7.zip
サムネイル生成でエラーになってもファイルのアップロードを失敗しないように
#5050
Diffstat (limited to 'src/services/drive')
-rw-r--r--src/services/drive/add-file.ts54
1 files changed, 31 insertions, 23 deletions
diff --git a/src/services/drive/add-file.ts b/src/services/drive/add-file.ts
index d21c67d180..a2143ca608 100644
--- a/src/services/drive/add-file.ts
+++ b/src/services/drive/add-file.ts
@@ -149,18 +149,22 @@ export async function generateAlts(path: string, type: string, generateWeb: bool
if (generateWeb) {
logger.info(`creating web image`);
- if (['image/jpeg'].includes(type)) {
- webpublic = await convertToJpeg(path, 2048, 2048);
- } else if (['image/webp'].includes(type)) {
- webpublic = await convertToWebp(path, 2048, 2048);
- } else if (['image/png'].includes(type)) {
- webpublic = await convertToPng(path, 2048, 2048);
- } else if (['image/apng', 'image/vnd.mozilla.apng'].includes(type)) {
- webpublic = await convertToApng(path);
- } else if (['image/gif'].includes(type)) {
- webpublic = await convertToGif(path);
- } else {
- logger.info(`web image not created (not an image)`);
+ try {
+ if (['image/jpeg'].includes(type)) {
+ webpublic = await convertToJpeg(path, 2048, 2048);
+ } else if (['image/webp'].includes(type)) {
+ webpublic = await convertToWebp(path, 2048, 2048);
+ } else if (['image/png'].includes(type)) {
+ webpublic = await convertToPng(path, 2048, 2048);
+ } else if (['image/apng', 'image/vnd.mozilla.apng'].includes(type)) {
+ webpublic = await convertToApng(path);
+ } else if (['image/gif'].includes(type)) {
+ webpublic = await convertToGif(path);
+ } else {
+ logger.info(`web image not created (not an image)`);
+ }
+ } catch (e) {
+ logger.warn(`web image not created (an error occured)`, e);
}
} else {
logger.info(`web image not created (from remote)`);
@@ -170,18 +174,22 @@ export async function generateAlts(path: string, type: string, generateWeb: bool
// #region thumbnail
let thumbnail: IImage | null = null;
- if (['image/jpeg', 'image/webp'].includes(type)) {
- thumbnail = await convertToJpeg(path, 498, 280);
- } else if (['image/png'].includes(type)) {
- thumbnail = await convertToPng(path, 498, 280);
- } else if (['image/gif'].includes(type)) {
- thumbnail = await convertToGif(path);
- } else if (type.startsWith('video/')) {
- try {
- thumbnail = await GenerateVideoThumbnail(path);
- } catch (e) {
- logger.error(`GenerateVideoThumbnail failed: ${e}`);
+ try {
+ if (['image/jpeg', 'image/webp'].includes(type)) {
+ thumbnail = await convertToJpeg(path, 498, 280);
+ } else if (['image/png'].includes(type)) {
+ thumbnail = await convertToPng(path, 498, 280);
+ } else if (['image/gif'].includes(type)) {
+ thumbnail = await convertToGif(path);
+ } else if (type.startsWith('video/')) {
+ try {
+ thumbnail = await GenerateVideoThumbnail(path);
+ } catch (e) {
+ logger.error(`GenerateVideoThumbnail failed: ${e}`);
+ }
}
+ } catch (e) {
+ logger.warn(`thumbnail not created (an error occured)`, e);
}
// #endregion thumbnail