Skip to content

TagSpaces is an offline, open source, document manager with tagging support

Generating thumbnails for video files with # in the name is failing (#1546)

Stanimir934ce1234f21
diff --git a/app/components/LocationView.tsx b/app/components/LocationView.tsx
index ee2630bc1..56a246df1 100644
--- a/app/components/LocationView.tsx
+++ b/app/components/LocationView.tsx
@@ -105,7 +105,7 @@ const LocationView = (props: Props) => {
const handleLocationClick = () => {
if (location.uuid === props.currentLocationId) {
// the same location click
- props.loadDirectoryContent(getLocationPath(location), false);
+ props.loadDirectoryContent(getLocationPath(location), true); // false);
} else {
// this.directoryTreeRef[location.uuid].loadSubDir(location, 1);
props.setSelectedEntries([]);
diff --git a/app/package-template.json b/app/package-template.json
index de1b0e3ad..767a6c541 100644
--- a/app/package-template.json
+++ b/app/package-template.json
@@ -4,7 +4,7 @@
},
"nodeDependencies": {
"@tagspaces/extensions": "1.0.10",
- "sharp": "^0.29.2",
- "@tagspaces/tagspaces-ws": "1.0.26"
+ "@tagspaces/tagspaces-ws": "1.0.27",
+ "sharp": "^0.29.2"
}
}
diff --git a/app/package.json b/app/package.json
index 80e086f9e..2d64ca048 100644
--- a/app/package.json
+++ b/app/package.json
@@ -14,7 +14,7 @@
"scripts": {},
"dependencies": {
"@tagspaces/extensions": "1.0.10",
- "@tagspaces/tagspaces-ws": "1.0.26",
+ "@tagspaces/tagspaces-ws": "1.0.27",
"sharp": "^0.29.2"
}
}
diff --git a/app/services/electron-io.ts b/app/services/electron-io.ts
index 72f084665..19e10baaf 100644
--- a/app/services/electron-io.ts
+++ b/app/services/electron-io.ts
@@ -527,7 +527,7 @@ export default class ElectronIO {
const thumbFilePath =
metaFolderPath +
AppConfig.dirSeparator +
- metaEntryName;
+ encodeURIComponent(metaEntryName);
enhancedEntry.thumbPath = thumbFilePath;
}
return true;
diff --git a/app/services/thumbsgenerator.ts b/app/services/thumbsgenerator.ts
index 9731b4751..3c826640e 100644
--- a/app/services/thumbsgenerator.ts
+++ b/app/services/thumbsgenerator.ts
@@ -16,15 +16,16 @@
*
*/
-import EXIF from 'exif-js';
+// import EXIF from 'exif-js';
import {
extractFileExtension,
extractContainingDirectoryPath,
extractFileName,
normalizePath,
- getMetaDirectoryPath
-} from '../utils/paths';
-import { base64ToArrayBuffer } from '../utils/misc';
+ getMetaDirectoryPath,
+ encodeFileName
+} from '-/utils/paths';
+import { base64ToArrayBuffer } from '-/utils/misc';
import AppConfig from '../config';
import PlatformIO from '../services/platform-io';
import { Pro } from '../pro';
@@ -255,37 +256,42 @@ export function generateThumbnailPromise(fileURL: string, fileSize: number) {
PlatformIO.getDirSeparator()
).toLowerCase();
+ const fileURLEscaped = encodeFileName(fileURL, PlatformIO.getDirSeparator());
+
if (supportedImgs.indexOf(ext) >= 0) {
if (fileSize && fileSize < maxFileSize) {
- return generateImageThumbnail(fileURL);
+ return generateImageThumbnail(fileURLEscaped);
}
} else if (Pro && ext === 'pdf') {
- return Pro.ThumbsGenerator.generatePDFThumbnail(fileURL, maxSize);
+ return Pro.ThumbsGenerator.generatePDFThumbnail(fileURLEscaped, maxSize);
} else if (Pro && ext === 'html') {
- return Pro.ThumbsGenerator.generateHtmlThumbnail(fileURL, maxSize);
+ return Pro.ThumbsGenerator.generateHtmlThumbnail(fileURLEscaped, maxSize);
} else if (Pro && ext === 'url') {
- return Pro.ThumbsGenerator.generateUrlThumbnail(fileURL, maxSize);
+ return Pro.ThumbsGenerator.generateUrlThumbnail(fileURLEscaped, maxSize);
} else if (Pro && ext === 'tiff') {
- return Pro.ThumbsGenerator.generateTiffThumbnail(fileURL, maxSize);
+ return Pro.ThumbsGenerator.generateTiffThumbnail(fileURLEscaped, maxSize);
} else if (Pro && ext === 'mp3') {
if (fileSize && fileSize < maxFileSize) {
// return Pro.ThumbsGenerator.generateMp3Thumbnail(fileURL, maxSize);
}
} else if (Pro && supportedText.indexOf(ext) >= 0) {
- return Pro.ThumbsGenerator.generateTextThumbnail(fileURL, maxSize);
+ return Pro.ThumbsGenerator.generateTextThumbnail(fileURLEscaped, maxSize);
} else if (Pro && supportedContainers.indexOf(ext) >= 0) {
if (fileSize && fileSize < maxFileSize) {
return Pro.ThumbsGenerator.generateZipContainerImageThumbnail(
- fileURL,
+ fileURLEscaped,
maxSize,
supportedImgs
);
}
} else if (supportedVideos.indexOf(ext) >= 0) {
if (Pro) {
- return Pro.ThumbsGenerator.generateVideoThumbnail(fileURL, maxSize);
+ return Pro.ThumbsGenerator.generateVideoThumbnail(
+ fileURLEscaped,
+ maxSize
+ );
}
- return generateVideoThumbnail(fileURL);
+ return generateVideoThumbnail(fileURLEscaped);
}
return generateDefaultThumbnail();
}
diff --git a/app/utils/paths.ts b/app/utils/paths.ts
index 01d60fa83..3026cf43b 100644
--- a/app/utils/paths.ts
+++ b/app/utils/paths.ts
@@ -116,6 +116,10 @@ export function getThumbFileLocationForFile(
entryPath: string,
dirSeparator: string // = AppConfig.dirSeparator
) {
+ if (entryPath.indexOf(dirSeparator + AppConfig.metaFolder) > -1) {
+ // entryPath is in .ts folder - no thumb file location exist
+ return undefined;
+ }
const containingFolder = extractContainingDirectoryPath(
entryPath,
dirSeparator
@@ -124,7 +128,7 @@ export function getThumbFileLocationForFile(
return (
metaFolder +
dirSeparator +
- extractFileName(entryPath, dirSeparator) +
+ encodeURIComponent(extractFileName(entryPath, dirSeparator)) +
AppConfig.thumbFileExt
);
}
@@ -166,6 +170,24 @@ export function extractFileName(
return filePath;
}
+export function encodeFileName(
+ filePath: string,
+ dirSeparator: string // = AppConfig.dirSeparator
+): string {
+ if (filePath) {
+ const path = filePath;
+ if (filePath.endsWith(dirSeparator)) {
+ return '';
+ }
+ const lastDirSeparator = path.lastIndexOf(dirSeparator) + 1;
+ return (
+ path.substring(0, lastDirSeparator) +
+ encodeURIComponent(path.substring(lastDirSeparator, path.length))
+ );
+ }
+ return filePath;
+}
+
export function cleanTrailingDirSeparator(dirPath: string): string {
if (dirPath) {
if (dirPath.lastIndexOf('\\') === dirPath.length - 1) {
diff --git a/package.json b/package.json
index e86d36e9b..a0b0649ba 100644
--- a/package.json
+++ b/package.json
@@ -81,11 +81,8 @@
"paste-android-linux": "adb shell input text '$(xclip -selection c -o)'",
"paste-android-macos": "adb shell input text \"'$(pbpaste)'\"",
"playwright-show-trace": "npx playwright show-trace \"tests/test-reports/TST0813 - Delete file [web,minio,electron].zip\"",
- "postinstall-cordova": "cross-env PD_PLATFORM=cordova yarn upgrade @tagspaces/tagspaces-platforms@$ts_platform_version",
"postinstall-cordova-check": "cross-env PD_PLATFORM=cordova node scripts/postinstall.js",
- "postinstall-node": "cross-env PD_PLATFORM=node yarn upgrade @tagspaces/tagspaces-platforms@$ts_platform_version",
"postinstall-node-check": "cross-env PD_PLATFORM=node node scripts/postinstall.js",
- "postinstall-web": "cross-env PD_PLATFORM=web yarn upgrade @tagspaces/tagspaces-platforms@$ts_platform_version",
"postinstall-web-check": "cross-env PD_PLATFORM=web node scripts/postinstall.js",
"precommit": "lint-staged",
"prepare-cordova": "yarn install-ext-web && yarn postinstall-cordova-check && rimraf cordova/www/dist && rimraf cordova/www/node_modules && shx cp -rL app/node_modules cordova/www && shx cp LICENSE.txt cordova/www",
@@ -152,7 +149,7 @@
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.57",
"@material-ui/pickers": "^3.2.10",
- "@tagspaces/tagspaces-platforms": "1.0.59",
+ "@tagspaces/tagspaces-platforms": "1.0.61",
"aws-amplify": "^3.3.27",
"aws-sdk": "^2.984.0",
"babel-polyfill": "^6.26.0",
diff --git a/scripts/postinstall.js b/scripts/postinstall.js
index c44360999..03e90c4a2 100644
--- a/scripts/postinstall.js
+++ b/scripts/postinstall.js
@@ -1,11 +1,8 @@
const fs = require('fs-extra');
const pathLib = require('path');
-const npm = require('npm');
+const shell = require('shelljs');
const packageJson = require('../package.json');
-process.env.ts_platform_version =
- packageJson.dependencies['@tagspaces/tagspaces-platforms'];
-
function isInstalled(npmPackage) {
// TODO check installed version
try {
@@ -23,8 +20,59 @@ function isInstalled(npmPackage) {
return false;
}
}
-if (process.env.PD_PLATFORM === 'node') {
- if (!isInstalled('@tagspaces/tagspaces-common-node')) {
+
+let install = false;
+if (process.env.PD_PLATFORM === 'electron') {
+ if (!isInstalled('@tagspaces/tagspaces-common-electron')) {
+ install = true;
+ }
+} else if (process.env.PD_PLATFORM === 'node') {
+ if (
+ !isInstalled('@tagspaces/tagspaces-common-node') ||
+ isInstalled('@tagspaces/tagspaces-common-electron')
+ ) {
+ install = true;
+ }
+} else if (process.env.PD_PLATFORM === 'web') {
+ if (!isInstalled('@tagspaces/tagspaces-common-aws')) {
+ install = true;
+ }
+} else if (process.env.PD_PLATFORM === 'cordova') {
+ if (!isInstalled('@tagspaces-common-cordova')) {
+ install = true;
+ }
+}
+
+if (
+ install &&
+ shell.exec(
+ 'yarn upgrade @tagspaces/tagspaces-platforms@' +
+ packageJson.dependencies['@tagspaces/tagspaces-platforms']
+ ).code !== 0
+) {
+ shell.echo('Error: Install ' + process.env.PD_PLATFORM + ' platform failed');
+ shell.exit(1);
+}
+
+/* if (process.env.PD_PLATFORM === 'electron') {
+ if (!isInstalled('@tagspaces/tagspaces-common-electron')) {
+ npm.load(er => {
+ if (er) {
+ console.log('err:', er);
+ return;
+ }
+ npm.commands.run(['postinstall-electron'], err => {
+ if (err) {
+ console.log('err:', err);
+ }
+ });
+ npm.on('log', message => {
+ console.log('npm:' + message);
+ });
+ });
+ }
+} else if (process.env.PD_PLATFORM === 'node') {
+ if (!isInstalled('@tagspaces/tagspaces-common-node') || isInstalled('@tagspaces/tagspaces-common-electron')) {
npm.load(er => {
if (er) {
console.log('err:', er);
@@ -74,4 +122,4 @@ if (process.env.PD_PLATFORM === 'node') {
});
});
}
-}
+} */
diff --git a/yarn.lock b/yarn.lock
index e170d6ebd..ed941da92 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3389,10 +3389,10 @@
dependencies:
defer-to-connect "^1.0.1"
-"@tagspaces/[email protected]":
- version "1.0.59"
- resolved "https://registry.yarnpkg.com/@tagspaces/tagspaces-platforms/-/tagspaces-platforms-1.0.59.tgz#1a5b0119d6fc1f6107d9fe5bc29d3a9602b2e7b9"
- integrity sha512-22gsOAcLzdHwvUhq2sa7eHc1ln2pK/AH9L3SwKOGzIhjSvRGhXfUOK+IBcPWHGF/d97WO5f487AreoMW9C0Xmw==
+"@tagspaces/[email protected]":
+ version "1.0.61"
+ resolved "https://registry.yarnpkg.com/@tagspaces/tagspaces-platforms/-/tagspaces-platforms-1.0.61.tgz#be707acb92012aa0d93641e418f71529ae76169e"
+ integrity sha512-gTWJpJ23XT9p6kIZSZDieZ0DycKDAxc/Yw9wTinEMlBl4YZ+jvwwtxyoylO+FMytxdH9p+70OgbvkA2xwadelA==
"@testim/chrome-version@^1.0.7":
version "1.0.7"