Skip to content

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

TSN288 improvements (#1106)

Stanimirf2e11e25e75d
diff --git a/app/reducers/app.ts b/app/reducers/app.ts
index 7bb1b902a..47351d4d7 100644
--- a/app/reducers/app.ts
+++ b/app/reducers/app.ts
@@ -381,13 +381,14 @@ export default (state: any = initialState, action: any) => {
const entryIndex = state.currentDirectoryEntries.findIndex(
entry => entry.path === action.newEntry.path
);
+ // clean all dir separators to have platform independent path match
if (
entryIndex < 0 &&
extractParentDirectoryPath(
action.newEntry.path,
PlatformIO.haveObjectStoreSupport() ? '/' : AppConfig.dirSeparator
- ).replace(/(^\/)|(\/$)/g, '') ===
- state.currentDirectoryPath.replace(/(^\/)|(\/$)|(^\\)|(\\$)/g, '')
+ ).replace(/[/\\]/g, '') ===
+ state.currentDirectoryPath.replace(/[/\\]/g, '')
) {
return {
...state,
@@ -668,7 +669,7 @@ export const actions = {
const { settings } = getState();
window.walkCanceled = false;
- loadMetaDataPromise(directoryPath)
+ loadMetaDataPromise(normalizePath(directoryPath) + AppConfig.dirSeparator)
.then(fsEntryMeta => {
if (fsEntryMeta.color) {
dispatch(actions.setCurrentDirectoryColor(fsEntryMeta.color));
@@ -830,10 +831,10 @@ export const actions = {
dispatch: (actions: Object) => void
) => {
PlatformIO.createDirectoryPromise(directoryPath)
- .then(normalizedDirPath => {
- if (normalizedDirPath !== undefined) {
+ .then(result => {
+ if (result !== undefined && result.dirPath !== undefined) {
// eslint-disable-next-line no-param-reassign
- directoryPath = normalizedDirPath;
+ directoryPath = result.dirPath;
}
console.log(`Creating directory ${directoryPath} successful.`);
dispatch(actions.reflectCreateEntry(directoryPath, false));
@@ -1215,9 +1216,14 @@ 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) : extractDirectoryName(path),
+ name: isFile
+ ? extractFileName(path, separator)
+ : extractDirectoryName(path, separator),
isFile,
extension: extractFileExtension(path),
description: '',