Skip to content

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

fix issues with file renaming and thumbnail showing in the entry properties

Ilian Sapundshiev6cba0d82037e
diff --git a/app/components/EntryProperties.tsx b/app/components/EntryProperties.tsx
index 0a4b483b1..ce22887b9 100644
--- a/app/components/EntryProperties.tsx
+++ b/app/components/EntryProperties.tsx
@@ -38,10 +38,12 @@ import { getAllPropertiesPromise } from '../services/utils-io';
import { formatFileSize } from '../utils/misc';
import {
extractContainingDirectoryPath,
- getThumbFileLocationForFile
+ getThumbFileLocationForFile,
+ getThumbFileLocationForDirectory
} from '../utils/paths';
import AppConfig from '../config';
import { Pro } from '../pro';
+import PlatformIO from '../services/platform-io';
import TagsSelect from './TagsSelect';
import TransparentBackground from './TransparentBackground';
import {
@@ -271,7 +273,7 @@ class EntryProperties extends Component<Props, State> {
const { entryPath, renameFile, renameDirectory } = this.props;
const path = extractContainingDirectoryPath(entryPath);
- const nextPath = path + AppConfig.dirSeparator + name;
+ const nextPath = path + PlatformIO.directorySeparator + name;
this.setState(
{
@@ -423,7 +425,7 @@ class EntryProperties extends Component<Props, State> {
})
.catch(err => {
console.warn('Error replaceThumbnailURLPromise ' + err);
- this.props.showNotification('Error replace Thumbnail');
+ this.props.showNotification('Error replacing thumbnail');
});
}
// reset Thumbnail
@@ -555,16 +557,17 @@ class EntryProperties extends Component<Props, State> {
return <div />;
}
- if (thumbPath === undefined) {
+ if (!thumbPath) {
if (isFile) {
- thumbPath = getThumbFileLocationForFile(path);
+ thumbPath = getThumbFileLocationForFile(
+ path,
+ PlatformIO.directorySeparator
+ );
} else {
- thumbPath =
- path +
- AppConfig.dirSeparator +
- AppConfig.metaFolder +
- AppConfig.dirSeparator +
- AppConfig.folderThumbFile;
+ thumbPath = getThumbFileLocationForDirectory(
+ path,
+ PlatformIO.directorySeparator
+ );
}
}
let thumbPathUrl = thumbPath
diff --git a/app/services/platform-io.ts b/app/services/platform-io.ts
index 48be1a506..5c5c60a1e 100644
--- a/app/services/platform-io.ts
+++ b/app/services/platform-io.ts
@@ -19,6 +19,7 @@
import { Pro } from '../pro';
// @ts-ignore
import NativePlatformIO from './_PLATFORMIO_';
+import AppConfig from '-/config';
const nativeAPI: any = new NativePlatformIO();
let objectStoreAPI;
@@ -48,6 +49,10 @@ export default class PlatformIO {
static haveObjectStoreSupport = (): boolean => objectStoreAPI !== undefined;
+ static directorySeparator: string = PlatformIO.haveObjectStoreSupport()
+ ? '/'
+ : AppConfig.dirSeparator;
+
static initMainMenu = (menuConfig: Array<Object>): void => {
if (nativeAPI.initMainMenu) {
nativeAPI.initMainMenu(menuConfig);
diff --git a/app/utils/paths.ts b/app/utils/paths.ts
index 347351296..c3677513e 100644
--- a/app/utils/paths.ts
+++ b/app/utils/paths.ts
@@ -104,6 +104,19 @@ export function getThumbFileLocationForFile(
);
}
+export function getThumbFileLocationForDirectory(
+ entryPath: string,
+ dirSeparator: string = AppConfig.dirSeparator
+) {
+ return (
+ entryPath +
+ dirSeparator +
+ AppConfig.metaFolder +
+ dirSeparator +
+ AppConfig.folderThumbFile
+ );
+}
+
export function getMetaFileLocationForDir(entryPath: string) {
const metaFolder = getMetaDirectoryPath(entryPath);
return metaFolder + AppConfig.dirSeparator + AppConfig.metaFolderFile;
@@ -191,7 +204,7 @@ export function extractParentDirectoryPath(
if (lastIndex !== -1) {
return path.substring(0, lastIndex);
}
- //return root dir in cases that dirPath not start with dirSeparator (AWS)
+ // return root dir in cases that dirPath not start with dirSeparator (AWS)
return '';
}