Skip to content

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

fix: handling object storage on windows

Ilian Sapundshiev579f84dbc2e4
diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsx
index 8df011cb4..ea33ffa02 100644
--- a/app/components/EntryContainer.tsx
+++ b/app/components/EntryContainer.tsx
@@ -905,7 +905,11 @@ class EntryContainer extends React.Component<Props, State> {
let fileTitle: string = '';
if (currentEntry && currentEntry.path) {
- fileTitle = extractTitle(currentEntry.path, !currentEntry.isFile);
+ fileTitle = extractTitle(
+ currentEntry.path,
+ !currentEntry.isFile,
+ PlatformIO.directorySeparator()
+ );
// if (fileTitle.length > maxCharactersTitleLength) {
// fileTitle = fileTitle.substr(0, maxCharactersTitleLength) + '...';
// }
@@ -1026,9 +1030,7 @@ class EntryContainer extends React.Component<Props, State> {
dirPath: currentEntry
? extractDirectoryName(
currentEntry.path,
- PlatformIO.haveObjectStoreSupport()
- ? '/'
- : AppConfig.dirSeparator
+ PlatformIO.directorySeparator()
)
: ''
})
diff --git a/app/components/EntryProperties.tsx b/app/components/EntryProperties.tsx
index ce22887b9..be7a491d6 100644
--- a/app/components/EntryProperties.tsx
+++ b/app/components/EntryProperties.tsx
@@ -272,8 +272,11 @@ class EntryProperties extends Component<Props, State> {
const { name, isFile } = this.state;
const { entryPath, renameFile, renameDirectory } = this.props;
- const path = extractContainingDirectoryPath(entryPath);
- const nextPath = path + PlatformIO.directorySeparator + name;
+ const path = extractContainingDirectoryPath(
+ entryPath,
+ PlatformIO.directorySeparator()
+ );
+ const nextPath = path + PlatformIO.directorySeparator() + name;
this.setState(
{
@@ -561,21 +564,21 @@ class EntryProperties extends Component<Props, State> {
if (isFile) {
thumbPath = getThumbFileLocationForFile(
path,
- PlatformIO.directorySeparator
+ PlatformIO.directorySeparator()
);
} else {
thumbPath = getThumbFileLocationForDirectory(
path,
- PlatformIO.directorySeparator
+ PlatformIO.directorySeparator()
);
}
}
- let thumbPathUrl = thumbPath
+ const thumbPathUrl = thumbPath
? 'url("' + thumbPath + '?' + new Date().getTime() + '")'
: '';
- if (AppConfig.isWin) {
- thumbPathUrl = thumbPathUrl.split('\\').join('\\\\');
- }
+ // if (AppConfig.isWin) {
+ // thumbPathUrl = thumbPathUrl.split('\\').join('\\\\');
+ // }
return (
<div className={classes.entryProperties}>
diff --git a/app/components/dialogs/CreateDialog.tsx b/app/components/dialogs/CreateDialog.tsx
index 1f6cec79a..76fa63340 100644
--- a/app/components/dialogs/CreateDialog.tsx
+++ b/app/components/dialogs/CreateDialog.tsx
@@ -32,7 +32,6 @@ import Grid from '@material-ui/core/Grid';
import { withStyles } from '@material-ui/core/styles';
import withMobileDialog from '@material-ui/core/withMobileDialog';
import Dialog from '@material-ui/core/Dialog';
-// import Slide from '@material-ui/core/Slide';
import i18n from '-/services/i18n';
import { getKeyBindingObject } from '-/reducers/settings';
import { actions as AppActions } from '-/reducers/app';
@@ -41,10 +40,6 @@ import { normalizePath } from '-/utils/paths';
import PlatformIO from '-/services/platform-io';
import { formatDateTime4Tag } from '-/utils/misc';
-// const Transition = React.forwardRef(function Transition(props, ref) {
-// return <Slide direction="down" ref={ref} {...props} />;
-// });
-
const styles: any = () => ({
root: {
dispatch: 'flex',
diff --git a/app/components/dialogs/CreateDirectoryDialog.tsx b/app/components/dialogs/CreateDirectoryDialog.tsx
index 6e4190d54..303189cfb 100644
--- a/app/components/dialogs/CreateDirectoryDialog.tsx
+++ b/app/components/dialogs/CreateDirectoryDialog.tsx
@@ -28,8 +28,8 @@ import FormControl from '@material-ui/core/FormControl';
import FormHelperText from '@material-ui/core/FormHelperText';
import Dialog from '@material-ui/core/Dialog';
import i18n from '-/services/i18n';
-import AppConfig from '-/config';
import { actions as AppActions } from '-/reducers/app';
+import PlatformIO from '-/services/platform-io';
interface Props {
open: boolean;
@@ -64,7 +64,7 @@ const CreateDirectoryDialog = (props: Props) => {
function onConfirm() {
if (!disableConfirmButton && name) {
const dirPath =
- props.selectedDirectoryPath + AppConfig.dirSeparator + name;
+ props.selectedDirectoryPath + PlatformIO.directorySeparator() + name;
props.createDirectory(dirPath);
resetState();
props.onClose();
diff --git a/app/components/dialogs/RenameFileDialog.tsx b/app/components/dialogs/RenameFileDialog.tsx
index fe5edc662..68b09026c 100644
--- a/app/components/dialogs/RenameFileDialog.tsx
+++ b/app/components/dialogs/RenameFileDialog.tsx
@@ -32,6 +32,7 @@ import AppConfig from '-/config';
import i18n from '-/services/i18n';
import { extractFileName, extractContainingDirectoryPath } from '-/utils/paths';
import { actions as AppActions } from '-/reducers/app';
+import PlatformIO from '-/services/platform-io';
interface Props {
open: boolean;
@@ -111,7 +112,7 @@ class RenameFileDialog extends React.Component<Props, State> {
this.props.selectedFilePath
);
const newFilePath =
- fileDirectory + AppConfig.dirSeparator + this.state.fileName;
+ fileDirectory + PlatformIO.directorySeparator + this.state.fileName;
this.props.renameFile(this.props.selectedFilePath, newFilePath);
this.props.onClose();
this.setState({ inputError: false, disableConfirmButton: true });
diff --git a/app/components/dialogs/SelectDirectoryDialog.tsx b/app/components/dialogs/SelectDirectoryDialog.tsx
index 6e0775248..7dd1f4a9a 100644
--- a/app/components/dialogs/SelectDirectoryDialog.tsx
+++ b/app/components/dialogs/SelectDirectoryDialog.tsx
@@ -199,7 +199,7 @@ class SelectDirectoryDialog extends React.Component<Props, State> {
onBackButton = () => {
const lastIndex = this.state.currentPath.lastIndexOf(
- AppConfig.dirSeparator
+ PlatformIO.directorySeparator()
);
const path = this.state.currentPath.slice(0, lastIndex);
this.setState({
diff --git a/app/components/menus/DirectoryMenu.tsx b/app/components/menus/DirectoryMenu.tsx
index 2988f8271..d81691b0b 100644
--- a/app/components/menus/DirectoryMenu.tsx
+++ b/app/components/menus/DirectoryMenu.tsx
@@ -178,7 +178,9 @@ const DirectoryMenu = (props: Props) => {
AppConfig.endTagContainer +
'.jpg';
const newFilePath =
- normalizePath(props.directoryPath) + AppConfig.dirSeparator + fileName;
+ normalizePath(props.directoryPath) +
+ PlatformIO.directorySeparator() +
+ fileName;
PlatformIO.renameFilePromise(filePath, newFilePath)
.then(() => {
@@ -290,10 +292,7 @@ const DirectoryMenu = (props: Props) => {
}
function getDirPath(dirPath: string) {
- const fileName = extractFileName(
- dirPath,
- PlatformIO.haveObjectStoreSupport() ? '/' : AppConfig.dirSeparator
- );
+ const fileName = extractFileName(dirPath, PlatformIO.directorySeparator());
return props.directoryPath && fileName
? fileName
: cleanTrailingDirSeparator(props.directoryPath);
diff --git a/app/reducers/app.ts b/app/reducers/app.ts
index 927017a64..6ab265649 100644
--- a/app/reducers/app.ts
+++ b/app/reducers/app.ts
@@ -391,7 +391,7 @@ export default (state: any = initialState, action: any) => {
entryIndex < 0 &&
extractParentDirectoryPath(
action.newEntry.path,
- PlatformIO.haveObjectStoreSupport() ? '/' : AppConfig.dirSeparator
+ PlatformIO.directorySeparator()
).replace(/[/\\]/g, '') ===
state.currentDirectoryPath.replace(/[/\\]/g, '')
) {
@@ -416,7 +416,10 @@ export default (state: any = initialState, action: any) => {
...entry,
path: action.newPath,
// thumbPath: getThumbFileLocationForFile(action.newPath), // not needed due timing issue
- name: extractFileName(action.newPath),
+ name: extractFileName(
+ action.newPath,
+ PlatformIO.directorySeparator()
+ ),
extension: extractFileExtension(action.newPath),
tags: [
...entry.tags.filter(tag => tag.type === 'sidecar'), // add only sidecar tags
@@ -637,12 +640,9 @@ export const actions = {
const currentLocationPath = normalizePath(getCurrentLocationPath(state));
if (currentDirectoryPath) {
- const dirSep = PlatformIO.haveObjectStoreSupport()
- ? '/'
- : AppConfig.dirSeparator;
const parentDirectory = extractParentDirectoryPath(
currentDirectoryPath,
- dirSep
+ PlatformIO.directorySeparator()
);
// console.log('parentDirectory: ' + parentDirectory + ' - currentLocationPath: ' + currentLocationPath);
if (parentDirectory.includes(currentLocationPath)) {
@@ -674,7 +674,9 @@ export const actions = {
const { settings } = getState();
window.walkCanceled = false;
- loadMetaDataPromise(normalizePath(directoryPath) + AppConfig.dirSeparator)
+ loadMetaDataPromise(
+ normalizePath(directoryPath) + PlatformIO.directorySeparator()
+ )
.then(fsEntryMeta => {
if (fsEntryMeta.color) {
dispatch(actions.setCurrentDirectoryColor(fsEntryMeta.color));
@@ -712,7 +714,7 @@ export const actions = {
showIsLoading?: boolean
) => ({
type: types.LOAD_DIRECTORY_SUCCESS,
- directoryPath: directoryPath || AppConfig.dirSeparator,
+ directoryPath: directoryPath || PlatformIO.directorySeparator(),
directoryContent,
showIsLoading
}),
@@ -768,9 +770,7 @@ export const actions = {
i18n.t('deletingDirectorySuccessfull', {
dirPath: extractDirectoryName(
directoryPath,
- PlatformIO.haveObjectStoreSupport()
- ? '/'
- : AppConfig.dirSeparator
+ PlatformIO.directorySeparator()
)
}),
'default',
@@ -786,9 +786,7 @@ export const actions = {
i18n.t('errorDeletingDirectoryAlert', {
dirPath: extractDirectoryName(
directoryPath,
- PlatformIO.haveObjectStoreSupport()
- ? '/'
- : AppConfig.dirSeparator
+ PlatformIO.directorySeparator()
)
}),
'error',
@@ -874,7 +872,7 @@ export const actions = {
if (app.currentDirectoryPath) {
const filePath =
app.currentDirectoryPath +
- AppConfig.dirSeparator +
+ PlatformIO.directorySeparator() +
'textfile' +
AppConfig.beginTagContainer +
formatDateTime4Tag(new Date(), true) +
@@ -922,7 +920,9 @@ export const actions = {
) => (dispatch: (actions: Object) => void, getState: () => any) => {
const fileNameAndExt = fileName + '.' + fileType;
const filePath =
- normalizePath(targetPath) + AppConfig.dirSeparator + fileNameAndExt;
+ normalizePath(targetPath) +
+ PlatformIO.directorySeparator() +
+ fileNameAndExt;
let fileContent = content;
if (fileType === 'html') {
const { newHTMLFileContent } = getState().settings;
@@ -1221,14 +1221,11 @@ export const actions = {
reflectCreateEntry: (path: string, isFile: boolean) => (
dispatch: (actions: Object) => void
) => {
- const separator = PlatformIO.haveObjectStoreSupport()
- ? '/'
- : AppConfig.dirSeparator;
const newEntry = {
uuid: uuidv1(),
name: isFile
- ? extractFileName(path, separator)
- : extractDirectoryName(path, separator),
+ ? extractFileName(path, PlatformIO.directorySeparator())
+ : extractDirectoryName(path, PlatformIO.directorySeparator()),
isFile,
extension: extractFileExtension(path),
description: '',
@@ -1336,12 +1333,24 @@ export const actions = {
// Update sidecar file and thumb
renameFilesPromise([
[
- getMetaFileLocationForFile(filePath),
- getMetaFileLocationForFile(newFilePath)
+ getMetaFileLocationForFile(
+ filePath,
+ PlatformIO.directorySeparator()
+ ),
+ getMetaFileLocationForFile(
+ newFilePath,
+ PlatformIO.directorySeparator()
+ )
],
[
- getThumbFileLocationForFile(filePath),
- getThumbFileLocationForFile(newFilePath)
+ getThumbFileLocationForFile(
+ filePath,
+ PlatformIO.directorySeparator()
+ ),
+ getThumbFileLocationForFile(
+ newFilePath,
+ PlatformIO.directorySeparator()
+ )
]
])
.then(() => {
diff --git a/app/reducers/io-actions.ts b/app/reducers/io-actions.ts
index cc0e40aa3..84932cdd3 100644
--- a/app/reducers/io-actions.ts
+++ b/app/reducers/io-actions.ts
@@ -28,6 +28,7 @@ import AppConfig from '../config';
import i18n from '../services/i18n';
import { Pro } from '../pro';
import TaggingActions from './tagging-actions';
+import PlatformIO from '-/services/platform-io';
const actions = {
extractContent: (
@@ -71,8 +72,8 @@ const actions = {
moveJobs.push([
path,
normalizePath(targetPath) +
- AppConfig.dirSeparator +
- extractFileName(path)
+ PlatformIO.directorySeparator() +
+ extractFileName(path, PlatformIO.directorySeparator())
]);
return true;
});
@@ -119,8 +120,8 @@ const actions = {
copyJobs.push([
path,
normalizePath(targetPath) +
- AppConfig.dirSeparator +
- extractFileName(path)
+ PlatformIO.directorySeparator() +
+ extractFileName(path, PlatformIO.directorySeparator())
]);
return true;
});
diff --git a/app/reducers/location-index.ts b/app/reducers/location-index.ts
index 41b642356..a7779b381 100644
--- a/app/reducers/location-index.ts
+++ b/app/reducers/location-index.ts
@@ -118,7 +118,10 @@ export default (state: any = initialState, action: any) => {
if (GlobalSearch.index[i].path === action.path) {
GlobalSearch.index[i].path = action.newPath;
// thumbPath: getThumbFileLocationForFile(action.newPath), // disabled due performance concerns
- GlobalSearch.index[i].name = extractFileName(action.newPath);
+ GlobalSearch.index[i].name = extractFileName(
+ action.newPath,
+ PlatformIO.directorySeparator()
+ );
GlobalSearch.index[i].extension = extractFileExtension(
action.newPath
);
@@ -129,29 +132,6 @@ export default (state: any = initialState, action: any) => {
}
}
return state;
- /* const indexForRenamingInIndex = state.currentDirectoryIndex.findIndex((entry) => entry.path === action.path);
- if (indexForRenamingInIndex >= 0) {
- const updateEntry = {
- ...state.currentDirectoryIndex[indexForRenamingInIndex],
- path: action.newPath,
- // thumbPath: getThumbFileLocationForFile(action.newPath), // disabled due performance concerns
- name: extractFileName(action.newPath),
- extension: extractFileExtension(action.newPath),
- tags: [
- ...state.currentDirectoryIndex[indexForRenamingInIndex].tags.filter(tag => tag.type === 'sidecar'), // add only sidecar tags
- ...extractTagsAsObjects(action.newPath) // , getTagDelimiter(state))
- ]
- };
- return {
- ...state,
- currentDirectoryIndex: [
- ...state.currentDirectoryIndex.slice(0, indexForRenamingInIndex),
- updateEntry,
- ...state.currentDirectoryIndex.slice(indexForRenamingInIndex + 1)
- ]
- };
- }
- return state; */
}
case types.REFLECT_UPDATE_SIDECARTAGS: {
for (let i = 0; i < GlobalSearch.index.length; i += 1) {
@@ -163,25 +143,6 @@ export default (state: any = initialState, action: any) => {
}
}
return state;
- /* const indexForUpdatingInIndex = state.currentDirectoryIndex.findIndex((entry) => entry.path === action.path);
- if (indexForUpdatingInIndex >= 0) {
- const updateEntry = {
- ...state.currentDirectoryIndex[indexForUpdatingInIndex],
- tags: [
- ...state.currentDirectoryIndex[indexForUpdatingInIndex].tags.filter(tag => tag.type === 'plain'),
- ...action.tags
- ]
- };
- return {
- ...state,
- currentDirectoryIndex: [
- ...state.currentDirectoryIndex.slice(0, indexForUpdatingInIndex),
- updateEntry,
- ...state.currentDirectoryIndex.slice(indexForUpdatingInIndex + 1)
- ]
- };
- }
- return state; */
}
case types.REFLECT_UPDATE_SIDECARMETA: {
for (let i = 0; i < GlobalSearch.index.length; i += 1) {
@@ -193,22 +154,6 @@ export default (state: any = initialState, action: any) => {
}
}
return state;
- /* const indexForUpdatingInIndex = state.currentDirectoryIndex.findIndex((entry) => entry.path === action.path);
- if (indexForUpdatingInIndex >= 0) {
- const updateEntry = {
- ...state.currentDirectoryIndex[indexForUpdatingInIndex],
- ...action.entryMeta
- };
- return {
- ...state,
- currentDirectoryIndex: [
- ...state.currentDirectoryIndex.slice(0, indexForUpdatingInIndex),
- updateEntry,
- ...state.currentDirectoryIndex.slice(indexForUpdatingInIndex + 1)
- ]
- };
- }
- return state; */
}
default: {
return state;
@@ -246,9 +191,7 @@ export const actions = {
Pro.Indexer.persistIndex(
directoryPath,
directoryIndex,
- currentLocation.type === locationType.TYPE_CLOUD
- ? '/'
- : AppConfig.dirSeparator
+ PlatformIO.directorySeparator()
);
}
return true;
@@ -281,9 +224,7 @@ export const actions = {
Pro.Indexer.persistIndex(
nextPath,
directoryIndex,
- currentLocation.type === locationType.TYPE_CLOUD
- ? '/'
- : AppConfig.dirSeparator
+ PlatformIO.directorySeparator()
);
}
return true;
@@ -319,12 +260,7 @@ export const actions = {
AppActions.showNotification(i18n.t('core:loadingIndex'), 'default', true)
);
if (Pro && Pro.Indexer.loadIndex) {
- Pro.Indexer.loadIndex(
- directoryPath,
- currentLocation.type === locationType.TYPE_CLOUD
- ? '/'
- : AppConfig.dirSeparator
- )
+ Pro.Indexer.loadIndex(directoryPath, PlatformIO.directorySeparator())
.then(directoryIndex => {
if (isCurrentLocation) {
// Load index only if current location
@@ -408,7 +344,6 @@ export const actions = {
let directoryIndex = [];
let hasIndex = false;
const isCloudLocation = location.type === locationType.TYPE_CLOUD;
- const dirSeparator = isCloudLocation ? '/' : AppConfig.dirSeparator;
console.log('Searching in: ' + nextPath);
dispatch(
AppActions.showNotification(
@@ -430,13 +365,17 @@ export const actions = {
location.fullTextIndex
);
if (Pro && Pro.Indexer && Pro.Indexer.persistIndex) {
- Pro.Indexer.persistIndex(nextPath, directoryIndex, dirSeparator);
+ Pro.Indexer.persistIndex(
+ nextPath,
+ directoryIndex,
+ PlatformIO.directorySeparator()
+ );
}
} else if (Pro && Pro.Indexer && Pro.Indexer.loadIndex) {
console.log('Loading index for : ' + nextPath);
directoryIndex = await Pro.Indexer.loadIndex(
nextPath,
- dirSeparator
+ PlatformIO.directorySeparator()
);
}
return Search.searchLocationIndex(directoryIndex, searchQuery)
diff --git a/app/reducers/tagging-actions.ts b/app/reducers/tagging-actions.ts
index 517e6eaea..1c3a7a5a1 100644
--- a/app/reducers/tagging-actions.ts
+++ b/app/reducers/tagging-actions.ts
@@ -16,7 +16,6 @@
*
*/
-import uuidv1 from 'uuid';
import OpenLocationCode from 'open-location-code-typescript';
import i18n from '../services/i18n';
import { actions as AppActions } from './app';
@@ -215,7 +214,7 @@ const actions = {
}
const newFilePath =
containingDirectoryPath +
- AppConfig.dirSeparator +
+ PlatformIO.directorySeparator() +
generateFileName(fileName, extractedTags, settings.tagDelimiter);
dispatch(AppActions.renameFile(path, newFilePath));
}
@@ -233,7 +232,7 @@ const actions = {
}
const newFilePath =
containingDirectoryPath +
- AppConfig.dirSeparator +
+ PlatformIO.directorySeparator() +
generateFileName(fileName, extractedTags, settings.tagDelimiter);
if (path !== newFilePath) {
dispatch(AppActions.renameFile(path, newFilePath));
@@ -315,7 +314,9 @@ const actions = {
dispatch(
AppActions.renameFile(
path,
- containingDirectoryPath + AppConfig.dirSeparator + newFileName
+ containingDirectoryPath +
+ PlatformIO.directorySeparator() +
+ newFileName
)
);
}
@@ -497,7 +498,7 @@ const actions = {
}
const newFilePath =
containingDirectoryPath +
- AppConfig.dirSeparator +
+ PlatformIO.directorySeparator() +
generateFileName(fileName, extractedTags, settings.tagDelimiter);
if (path !== newFilePath) {
dispatch(AppActions.renameFile(path, newFilePath));
@@ -563,7 +564,7 @@ const actions = {
}
const newFilePath =
containingDirectoryPath +
- AppConfig.dirSeparator +
+ PlatformIO.directorySeparator() +
fileTitle +
fileExt;
dispatch(AppActions.renameFile(path, newFilePath));
@@ -609,7 +610,7 @@ const actions = {
}
}
var newFileName = generateFileName(fileName, extractedTags);
- renameFile(filePath, containingDirectoryPath + AppConfig.dirSeparator + newFileName); */
+ renameFile(filePath, containingDirectoryPath + PlatformIO.directorySeparator(), + newFileName); */
},
// smart tagging -> PRO
addDateTag: (paths: Array<string>) => () =>
diff --git a/app/services/platform-io.ts b/app/services/platform-io.ts
index 5c5c60a1e..66eb35f6a 100644
--- a/app/services/platform-io.ts
+++ b/app/services/platform-io.ts
@@ -49,9 +49,8 @@ export default class PlatformIO {
static haveObjectStoreSupport = (): boolean => objectStoreAPI !== undefined;
- static directorySeparator: string = PlatformIO.haveObjectStoreSupport()
- ? '/'
- : AppConfig.dirSeparator;
+ static directorySeparator = (): string =>
+ PlatformIO.haveObjectStoreSupport() ? '/' : AppConfig.dirSeparator;
static initMainMenu = (menuConfig: Array<Object>): void => {
if (nativeAPI.initMainMenu) {
diff --git a/app/services/thumbsgenerator.ts b/app/services/thumbsgenerator.ts
index 4452b55ef..3ab530a79 100644
--- a/app/services/thumbsgenerator.ts
+++ b/app/services/thumbsgenerator.ts
@@ -110,7 +110,7 @@ function getThumbFileLocation(filePath: string) {
const metaFolder = getMetaDirectoryPath(containingFolder);
return (
metaFolder +
- AppConfig.dirSeparator +
+ PlatformIO.directorySeparator() +
extractFileName(filePath) +
AppConfig.thumbFileExt
);
diff --git a/app/services/utils-io.ts b/app/services/utils-io.ts
index b49577491..304360488 100644
--- a/app/services/utils-io.ts
+++ b/app/services/utils-io.ts
@@ -242,9 +242,15 @@ export async function getAllPropertiesPromise(
const entryProps = await PlatformIO.getPropertiesPromise(entryPath);
let metaFilePath;
if (entryProps.isFile) {
- metaFilePath = getMetaFileLocationForFile(entryPath);
+ metaFilePath = getMetaFileLocationForFile(
+ entryPath,
+ PlatformIO.directorySeparator()
+ );
} else {
- metaFilePath = getMetaFileLocationForDir(entryPath);
+ metaFilePath = getMetaFileLocationForDir(
+ entryPath,
+ PlatformIO.directorySeparator()
+ );
}
const metaFileProps = await PlatformIO.getPropertiesPromise(metaFilePath);
if (metaFileProps.isFile) {
diff --git a/app/utils/paths.ts b/app/utils/paths.ts
index c3677513e..5ceff06f5 100644
--- a/app/utils/paths.ts
+++ b/app/utils/paths.ts
@@ -117,9 +117,12 @@ export function getThumbFileLocationForDirectory(
);
}
-export function getMetaFileLocationForDir(entryPath: string) {
+export function getMetaFileLocationForDir(
+ entryPath: string,
+ dirSeparator: string = AppConfig.dirSeparator
+) {
const metaFolder = getMetaDirectoryPath(entryPath);
- return metaFolder + AppConfig.dirSeparator + AppConfig.metaFolderFile;
+ return metaFolder + dirSeparator + AppConfig.metaFolderFile;
}
export function extractFileName(
@@ -157,8 +160,11 @@ export function normalizePath(path: string): string {
return cleanTrailingDirSeparator(path.replace(/\/\//g, '/'));
}
-export function extractFileNameWithoutExt(filePath: string): string {
- const fileName = extractFileName(filePath);
+export function extractFileNameWithoutExt(
+ filePath: string,
+ dirSeparator: string = AppConfig.dirSeparator
+): string {
+ const fileName = extractFileName(filePath, dirSeparator);
const indexOfDot = fileName.lastIndexOf('.');
const lastIndexBeginTagContainer = fileName.lastIndexOf(
AppConfig.beginTagContainer
@@ -254,13 +260,17 @@ export function extractContainingDirectoryName(filePath: string) {
);
}
-export function extractTitle(entryPath: string, isDirectory: boolean = false) {
+export function extractTitle(
+ entryPath: string,
+ isDirectory: boolean = false,
+ dirSeparator: string = AppConfig.dirSeparator
+) {
let title;
if (isDirectory) {
- title = extractDirectoryName(entryPath).replace(/(^\/)|(\/$)/g, '');
+ title = extractDirectoryName(entryPath, dirSeparator); // .replace(/(^\/)|(\/$)/g, '');
return title;
}
- title = extractFileNameWithoutExt(entryPath);
+ title = extractFileNameWithoutExt(entryPath, dirSeparator);
const beginTagContainer = title.indexOf(AppConfig.beginTagContainer);
const endTagContainer = title.lastIndexOf(AppConfig.endTagContainer);