TagSpaces is an offline, open source, document manager with tagging support
added loading persisted index
Ilian Sapundshievbedcdd8d9071
diff --git a/app/reducers/app.js b/app/reducers/app.jsindex 369c79732..76defdc45 100644--- a/app/reducers/app.js+++ b/app/reducers/app.js@@ -813,7 +813,11 @@ export const actions = {dispatch(actions.setCurrentLocationId(location.uuid));dispatch(actions.loadDirectoryContent(location.paths[0]));if (location.uuid !== currentLocationId) {- dispatch(LocationIndexActions.createDirectoryIndex(location.paths[0]));+ if (location.persistIndex) {+ dispatch(LocationIndexActions.loadDirectoryIndex(location.paths[0]));+ } else {+ dispatch(LocationIndexActions.createDirectoryIndex(location.paths[0]));+ }}return true;}).catch(() => {@@ -826,7 +830,11 @@ export const actions = {dispatch(actions.setCurrentLocationId(location.uuid));dispatch(actions.loadDirectoryContent(location.paths[0]));if (location.uuid !== currentLocationId) {- dispatch(LocationIndexActions.createDirectoryIndex(location.paths[0]));+ if (location.persistIndex) {+ dispatch(LocationIndexActions.loadDirectoryIndex(location.paths[0]));+ } else {+ dispatch(LocationIndexActions.createDirectoryIndex(location.paths[0]));+ }}if (Pro && Pro.Watcher && location.watchForChanges) {Pro.Watcher.watchFolder(location.paths[0], dispatch, actions);diff --git a/app/reducers/location-index.js b/app/reducers/location-index.jsindex 9fd870d48..215b894f1 100644--- a/app/reducers/location-index.js+++ b/app/reducers/location-index.js@@ -17,7 +17,7 @@* @flow*/-import { type Location, getLocation } from './locations';+import { type Location, getLocation, locationType } from './locations';import { createDirectoryIndex } from '../services/utils-io';import { Pro } from '../pro';import {@@ -29,6 +29,7 @@ import {import type { SearchQuery } from '../services/search';import Search from '../services/search';import { actions as AppActions } from './app';+import AppConfig from '../config';export const types = {INDEX_DIRECTORY: 'INDEX_DIRECTORY',@@ -201,7 +202,7 @@ export const actions = {.then(directoryIndex => {dispatch(actions.indexDirectorySuccess(directoryIndex));if (Pro && currentLocation.persistIndex) {- Pro.Indexer.persistIndex(directoryPath, directoryIndex);+ Pro.Indexer.persistIndex(directoryPath, directoryIndex, (currentLocation.type === locationType.TYPE_CLOUD) ? '/' : AppConfig.dirSeparator);}return true;})@@ -210,6 +211,24 @@ export const actions = {// dispatch(actions.startDirectoryIndexing());});},+ loadDirectoryIndex: (directoryPath: string) => (+ dispatch: (actions: Object) => void,+ getState: () => Object+ ) => {+ const state = getState();+ const currentLocation: Location = getLocation(state, state.app.currentLocationId);+ dispatch(actions.startDirectoryIndexing());+ dispatch(AppActions.showNotification('Loading index ...', 'default', true));+ if (Pro && Pro.Indexer.loadIndex) {+ Pro.Indexer.loadIndex(directoryPath, (currentLocation.type === locationType.TYPE_CLOUD) ? '/' : AppConfig.dirSeparator).then((directoryIndex) => {+ dispatch(actions.indexDirectorySuccess(directoryIndex));+ return true;+ }).catch(err => {+ dispatch(actions.indexDirectoryFailure(err));+ dispatch(AppActions.showNotification('Loading index failed', 'warning', true));+ });+ }+ },clearDirectoryIndex: () => ({type: types.INDEX_DIRECTORY_CLEAR}),