Skip to content

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

renaming directorySeparator to getDirSeparator

Ilian Sapundshiev85923c1c5b92
diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsx
index ea33ffa02..9fe18cd69 100644
--- a/app/components/EntryContainer.tsx
+++ b/app/components/EntryContainer.tsx
@@ -908,7 +908,7 @@ class EntryContainer extends React.Component<Props, State> {
fileTitle = extractTitle(
currentEntry.path,
!currentEntry.isFile,
- PlatformIO.directorySeparator()
+ PlatformIO.getDirSeparator()
);
// if (fileTitle.length > maxCharactersTitleLength) {
// fileTitle = fileTitle.substr(0, maxCharactersTitleLength) + '...';
@@ -1030,7 +1030,7 @@ class EntryContainer extends React.Component<Props, State> {
dirPath: currentEntry
? extractDirectoryName(
currentEntry.path,
- PlatformIO.directorySeparator()
+ PlatformIO.getDirSeparator()
)
: ''
})
diff --git a/app/components/EntryProperties.tsx b/app/components/EntryProperties.tsx
index be7a491d6..efb96bc0d 100644
--- a/app/components/EntryProperties.tsx
+++ b/app/components/EntryProperties.tsx
@@ -274,9 +274,9 @@ class EntryProperties extends Component<Props, State> {
const path = extractContainingDirectoryPath(
entryPath,
- PlatformIO.directorySeparator()
+ PlatformIO.getDirSeparator()
);
- const nextPath = path + PlatformIO.directorySeparator() + name;
+ const nextPath = path + PlatformIO.getDirSeparator() + name;
this.setState(
{
@@ -564,12 +564,12 @@ class EntryProperties extends Component<Props, State> {
if (isFile) {
thumbPath = getThumbFileLocationForFile(
path,
- PlatformIO.directorySeparator()
+ PlatformIO.getDirSeparator()
);
} else {
thumbPath = getThumbFileLocationForDirectory(
path,
- PlatformIO.directorySeparator()
+ PlatformIO.getDirSeparator()
);
}
}
diff --git a/app/components/dialogs/CreateDirectoryDialog.tsx b/app/components/dialogs/CreateDirectoryDialog.tsx
index 303189cfb..10156dfb7 100644
--- a/app/components/dialogs/CreateDirectoryDialog.tsx
+++ b/app/components/dialogs/CreateDirectoryDialog.tsx
@@ -64,7 +64,7 @@ const CreateDirectoryDialog = (props: Props) => {
function onConfirm() {
if (!disableConfirmButton && name) {
const dirPath =
- props.selectedDirectoryPath + PlatformIO.directorySeparator() + name;
+ props.selectedDirectoryPath + PlatformIO.getDirSeparator() + name;
props.createDirectory(dirPath);
resetState();
props.onClose();
diff --git a/app/components/dialogs/RenameFileDialog.tsx b/app/components/dialogs/RenameFileDialog.tsx
index 68b09026c..310d1a06a 100644
--- a/app/components/dialogs/RenameFileDialog.tsx
+++ b/app/components/dialogs/RenameFileDialog.tsx
@@ -112,7 +112,7 @@ class RenameFileDialog extends React.Component<Props, State> {
this.props.selectedFilePath
);
const newFilePath =
- fileDirectory + PlatformIO.directorySeparator + this.state.fileName;
+ fileDirectory + PlatformIO.getDirSeparator + 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 7dd1f4a9a..87bec9dff 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(
- PlatformIO.directorySeparator()
+ PlatformIO.getDirSeparator()
);
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 d81691b0b..66b8d9ed2 100644
--- a/app/components/menus/DirectoryMenu.tsx
+++ b/app/components/menus/DirectoryMenu.tsx
@@ -179,7 +179,7 @@ const DirectoryMenu = (props: Props) => {
'.jpg';
const newFilePath =
normalizePath(props.directoryPath) +
- PlatformIO.directorySeparator() +
+ PlatformIO.getDirSeparator() +
fileName;
PlatformIO.renameFilePromise(filePath, newFilePath)
@@ -292,7 +292,7 @@ const DirectoryMenu = (props: Props) => {
}
function getDirPath(dirPath: string) {
- const fileName = extractFileName(dirPath, PlatformIO.directorySeparator());
+ const fileName = extractFileName(dirPath, PlatformIO.getDirSeparator());
return props.directoryPath && fileName
? fileName
: cleanTrailingDirSeparator(props.directoryPath);
diff --git a/app/reducers/app.ts b/app/reducers/app.ts
index 6ab265649..5e1163ea0 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.directorySeparator()
+ PlatformIO.getDirSeparator()
).replace(/[/\\]/g, '') ===
state.currentDirectoryPath.replace(/[/\\]/g, '')
) {
@@ -416,10 +416,7 @@ export default (state: any = initialState, action: any) => {
...entry,
path: action.newPath,
// thumbPath: getThumbFileLocationForFile(action.newPath), // not needed due timing issue
- name: extractFileName(
- action.newPath,
- PlatformIO.directorySeparator()
- ),
+ name: extractFileName(action.newPath, PlatformIO.getDirSeparator()),
extension: extractFileExtension(action.newPath),
tags: [
...entry.tags.filter(tag => tag.type === 'sidecar'), // add only sidecar tags
@@ -642,7 +639,7 @@ export const actions = {
if (currentDirectoryPath) {
const parentDirectory = extractParentDirectoryPath(
currentDirectoryPath,
- PlatformIO.directorySeparator()
+ PlatformIO.getDirSeparator()
);
// console.log('parentDirectory: ' + parentDirectory + ' - currentLocationPath: ' + currentLocationPath);
if (parentDirectory.includes(currentLocationPath)) {
@@ -675,7 +672,7 @@ export const actions = {
window.walkCanceled = false;
loadMetaDataPromise(
- normalizePath(directoryPath) + PlatformIO.directorySeparator()
+ normalizePath(directoryPath) + PlatformIO.getDirSeparator()
)
.then(fsEntryMeta => {
if (fsEntryMeta.color) {
@@ -714,7 +711,7 @@ export const actions = {
showIsLoading?: boolean
) => ({
type: types.LOAD_DIRECTORY_SUCCESS,
- directoryPath: directoryPath || PlatformIO.directorySeparator(),
+ directoryPath: directoryPath || PlatformIO.getDirSeparator(),
directoryContent,
showIsLoading
}),
@@ -770,7 +767,7 @@ export const actions = {
i18n.t('deletingDirectorySuccessfull', {
dirPath: extractDirectoryName(
directoryPath,
- PlatformIO.directorySeparator()
+ PlatformIO.getDirSeparator()
)
}),
'default',
@@ -786,7 +783,7 @@ export const actions = {
i18n.t('errorDeletingDirectoryAlert', {
dirPath: extractDirectoryName(
directoryPath,
- PlatformIO.directorySeparator()
+ PlatformIO.getDirSeparator()
)
}),
'error',
@@ -872,7 +869,7 @@ export const actions = {
if (app.currentDirectoryPath) {
const filePath =
app.currentDirectoryPath +
- PlatformIO.directorySeparator() +
+ PlatformIO.getDirSeparator() +
'textfile' +
AppConfig.beginTagContainer +
formatDateTime4Tag(new Date(), true) +
@@ -920,9 +917,7 @@ export const actions = {
) => (dispatch: (actions: Object) => void, getState: () => any) => {
const fileNameAndExt = fileName + '.' + fileType;
const filePath =
- normalizePath(targetPath) +
- PlatformIO.directorySeparator() +
- fileNameAndExt;
+ normalizePath(targetPath) + PlatformIO.getDirSeparator() + fileNameAndExt;
let fileContent = content;
if (fileType === 'html') {
const { newHTMLFileContent } = getState().settings;
@@ -1224,8 +1219,8 @@ export const actions = {
const newEntry = {
uuid: uuidv1(),
name: isFile
- ? extractFileName(path, PlatformIO.directorySeparator())
- : extractDirectoryName(path, PlatformIO.directorySeparator()),
+ ? extractFileName(path, PlatformIO.getDirSeparator())
+ : extractDirectoryName(path, PlatformIO.getDirSeparator()),
isFile,
extension: extractFileExtension(path),
description: '',
@@ -1333,23 +1328,17 @@ export const actions = {
// Update sidecar file and thumb
renameFilesPromise([
[
- getMetaFileLocationForFile(
- filePath,
- PlatformIO.directorySeparator()
- ),
+ getMetaFileLocationForFile(filePath, PlatformIO.getDirSeparator()),
getMetaFileLocationForFile(
newFilePath,
- PlatformIO.directorySeparator()
+ PlatformIO.getDirSeparator()
)
],
[
- getThumbFileLocationForFile(
- filePath,
- PlatformIO.directorySeparator()
- ),
+ getThumbFileLocationForFile(filePath, PlatformIO.getDirSeparator()),
getThumbFileLocationForFile(
newFilePath,
- PlatformIO.directorySeparator()
+ PlatformIO.getDirSeparator()
)
]
])
diff --git a/app/reducers/io-actions.ts b/app/reducers/io-actions.ts
index 84932cdd3..f7b16bf63 100644
--- a/app/reducers/io-actions.ts
+++ b/app/reducers/io-actions.ts
@@ -72,8 +72,8 @@ const actions = {
moveJobs.push([
path,
normalizePath(targetPath) +
- PlatformIO.directorySeparator() +
- extractFileName(path, PlatformIO.directorySeparator())
+ PlatformIO.getDirSeparator() +
+ extractFileName(path, PlatformIO.getDirSeparator())
]);
return true;
});
@@ -120,8 +120,8 @@ const actions = {
copyJobs.push([
path,
normalizePath(targetPath) +
- PlatformIO.directorySeparator() +
- extractFileName(path, PlatformIO.directorySeparator())
+ PlatformIO.getDirSeparator() +
+ extractFileName(path, PlatformIO.getDirSeparator())
]);
return true;
});
diff --git a/app/reducers/location-index.ts b/app/reducers/location-index.ts
index a7779b381..7265cc944 100644
--- a/app/reducers/location-index.ts
+++ b/app/reducers/location-index.ts
@@ -120,7 +120,7 @@ export default (state: any = initialState, action: any) => {
// thumbPath: getThumbFileLocationForFile(action.newPath), // disabled due performance concerns
GlobalSearch.index[i].name = extractFileName(
action.newPath,
- PlatformIO.directorySeparator()
+ PlatformIO.getDirSeparator()
);
GlobalSearch.index[i].extension = extractFileExtension(
action.newPath
@@ -191,7 +191,7 @@ export const actions = {
Pro.Indexer.persistIndex(
directoryPath,
directoryIndex,
- PlatformIO.directorySeparator()
+ PlatformIO.getDirSeparator()
);
}
return true;
@@ -224,7 +224,7 @@ export const actions = {
Pro.Indexer.persistIndex(
nextPath,
directoryIndex,
- PlatformIO.directorySeparator()
+ PlatformIO.getDirSeparator()
);
}
return true;
@@ -260,7 +260,7 @@ export const actions = {
AppActions.showNotification(i18n.t('core:loadingIndex'), 'default', true)
);
if (Pro && Pro.Indexer.loadIndex) {
- Pro.Indexer.loadIndex(directoryPath, PlatformIO.directorySeparator())
+ Pro.Indexer.loadIndex(directoryPath, PlatformIO.getDirSeparator())
.then(directoryIndex => {
if (isCurrentLocation) {
// Load index only if current location
@@ -368,14 +368,14 @@ export const actions = {
Pro.Indexer.persistIndex(
nextPath,
directoryIndex,
- PlatformIO.directorySeparator()
+ PlatformIO.getDirSeparator()
);
}
} else if (Pro && Pro.Indexer && Pro.Indexer.loadIndex) {
console.log('Loading index for : ' + nextPath);
directoryIndex = await Pro.Indexer.loadIndex(
nextPath,
- PlatformIO.directorySeparator()
+ PlatformIO.getDirSeparator()
);
}
return Search.searchLocationIndex(directoryIndex, searchQuery)
diff --git a/app/reducers/tagging-actions.ts b/app/reducers/tagging-actions.ts
index 1c3a7a5a1..c3315bcbc 100644
--- a/app/reducers/tagging-actions.ts
+++ b/app/reducers/tagging-actions.ts
@@ -214,7 +214,7 @@ const actions = {
}
const newFilePath =
containingDirectoryPath +
- PlatformIO.directorySeparator() +
+ PlatformIO.getDirSeparator() +
generateFileName(fileName, extractedTags, settings.tagDelimiter);
dispatch(AppActions.renameFile(path, newFilePath));
}
@@ -232,7 +232,7 @@ const actions = {
}
const newFilePath =
containingDirectoryPath +
- PlatformIO.directorySeparator() +
+ PlatformIO.getDirSeparator() +
generateFileName(fileName, extractedTags, settings.tagDelimiter);
if (path !== newFilePath) {
dispatch(AppActions.renameFile(path, newFilePath));
@@ -314,9 +314,7 @@ const actions = {
dispatch(
AppActions.renameFile(
path,
- containingDirectoryPath +
- PlatformIO.directorySeparator() +
- newFileName
+ containingDirectoryPath + PlatformIO.getDirSeparator() + newFileName
)
);
}
@@ -498,7 +496,7 @@ const actions = {
}
const newFilePath =
containingDirectoryPath +
- PlatformIO.directorySeparator() +
+ PlatformIO.getDirSeparator() +
generateFileName(fileName, extractedTags, settings.tagDelimiter);
if (path !== newFilePath) {
dispatch(AppActions.renameFile(path, newFilePath));
@@ -564,7 +562,7 @@ const actions = {
}
const newFilePath =
containingDirectoryPath +
- PlatformIO.directorySeparator() +
+ PlatformIO.getDirSeparator() +
fileTitle +
fileExt;
dispatch(AppActions.renameFile(path, newFilePath));
@@ -610,7 +608,7 @@ const actions = {
}
}
var newFileName = generateFileName(fileName, extractedTags);
- renameFile(filePath, containingDirectoryPath + PlatformIO.directorySeparator(), + newFileName); */
+ renameFile(filePath, containingDirectoryPath + PlatformIO.getDirSeparator(), + newFileName); */
},
// smart tagging -> PRO
addDateTag: (paths: Array<string>) => () =>
diff --git a/app/services/platform-io.ts b/app/services/platform-io.ts
index 66eb35f6a..7d9e2a592 100644
--- a/app/services/platform-io.ts
+++ b/app/services/platform-io.ts
@@ -49,7 +49,7 @@ export default class PlatformIO {
static haveObjectStoreSupport = (): boolean => objectStoreAPI !== undefined;
- static directorySeparator = (): string =>
+ static getDirSeparator = (): string =>
PlatformIO.haveObjectStoreSupport() ? '/' : AppConfig.dirSeparator;
static initMainMenu = (menuConfig: Array<Object>): void => {
diff --git a/app/services/thumbsgenerator.ts b/app/services/thumbsgenerator.ts
index 3ab530a79..8671b0047 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 +
- PlatformIO.directorySeparator() +
+ PlatformIO.getDirSeparator() +
extractFileName(filePath) +
AppConfig.thumbFileExt
);
diff --git a/app/services/utils-io.ts b/app/services/utils-io.ts
index 304360488..59936f40b 100644
--- a/app/services/utils-io.ts
+++ b/app/services/utils-io.ts
@@ -244,12 +244,12 @@ export async function getAllPropertiesPromise(
if (entryProps.isFile) {
metaFilePath = getMetaFileLocationForFile(
entryPath,
- PlatformIO.directorySeparator()
+ PlatformIO.getDirSeparator()
);
} else {
metaFilePath = getMetaFileLocationForDir(
entryPath,
- PlatformIO.directorySeparator()
+ PlatformIO.getDirSeparator()
);
}
const metaFileProps = await PlatformIO.getPropertiesPromise(metaFilePath);