TagSpaces is an offline, open source, document manager with tagging support
add force indexing confirm dialog
Stanimirc2cbf06e072c
diff --git a/src/renderer/components/menus/LocationContextMenu.tsx b/src/renderer/components/menus/LocationContextMenu.tsxindex 0617218ce..e0cfa80ee 100644--- a/src/renderer/components/menus/LocationContextMenu.tsx+++ b/src/renderer/components/menus/LocationContextMenu.tsx@@ -76,7 +76,7 @@ function LocationContextMenu(props: Props) {const indexLocation = () => {setLocationDirectoryContextMenuAnchorEl(null);- createLocationIndex(selectedLocation);+ createLocationIndex(selectedLocation, true);};const showEditLocationDialog = () => {diff --git a/src/renderer/hooks/LocationIndexContextProvider.tsx b/src/renderer/hooks/LocationIndexContextProvider.tsxindex 03fb67d95..2570ec056 100644--- a/src/renderer/hooks/LocationIndexContextProvider.tsx+++ b/src/renderer/hooks/LocationIndexContextProvider.tsx@@ -56,7 +56,10 @@ type LocationIndexContextData = {getIndex: () => TS.FileSystemEntry[];getLastIndex: (locationId: string) => Promise<TS.FileSystemEntry[]>;cancelDirectoryIndexing: () => void;- createLocationIndex: (location: CommonLocation) => Promise<boolean>;+ createLocationIndex: (+ location: CommonLocation,+ force?: boolean,+ ) => Promise<boolean>;createLocationsIndexes: (extractText?: boolean) => Promise<boolean>;clearDirectoryIndex: (persist?: boolean) => void;searchLocationIndex: (searchQuery: TS.SearchQuery) => void;@@ -104,7 +107,8 @@ export const LocationIndexContextProvider = ({const { setSearchResults, appendSearchResults, updateCurrentDirEntries } =useDirectoryContentContext();const { actions } = useEditedEntryContext();- const { showNotification, hideNotifications } = useNotificationContext();+ const { showNotification, hideNotifications, openConfirmDialog } =+ useNotificationContext();const enableWS = useSelector(getEnableWS);//const allLocations = useSelector(getLocations);@@ -476,39 +480,63 @@ export const LocationIndexContextProvider = ({});}- function createLocationIndex(location: CommonLocation): Promise<boolean> {- if (location && !location.disableIndexing) {- return getLocationPath(location).then((locationPath) => {- const isCurrentLocation =- currentLocation && currentLocation.uuid === location.uuid;- isIndexing.current = location.name;- forceUpdate();- return createDirectoryIndexWrapper(- { path: locationPath, locationID: location.uuid },- location.fullTextIndex,- location.ignorePatternPaths,- enableWS,- )- .then((directoryIndex) => {- if (isCurrentLocation) {- // Load index only if current location- setIndex(directoryIndex);- }- isIndexing.current = undefined;- forceUpdate();- return true;- })- .catch((err) => {- isIndexing.current = undefined;- //lastError.current = err;- forceUpdate();- return false;- });- });+ function createLocationIndex(+ location: CommonLocation,+ force = false,+ ): Promise<boolean> {+ if (location) {+ if (location.disableIndexing) {+ if (force) {+ openConfirmDialog(+ t('core:confirm'),+ t('core:indexDisabledConfirm'),+ (result) => {+ if (result) {+ createLocationIndexInt(location);+ }+ },+ 'cancelIndexDisabledDialogTID',+ 'confirmIndexDisabledDialogTID',+ 'indexDisabledContentTID',+ );+ }+ } else {+ return createLocationIndexInt(location);+ }}return Promise.resolve(false);}+ function createLocationIndexInt(location: CommonLocation): Promise<boolean> {+ return getLocationPath(location).then((locationPath) => {+ const isCurrentLocation =+ currentLocation && currentLocation.uuid === location.uuid;+ isIndexing.current = location.name;+ forceUpdate();+ return createDirectoryIndexWrapper(+ { path: locationPath, locationID: location.uuid },+ location.fullTextIndex,+ location.ignorePatternPaths,+ enableWS,+ )+ .then((directoryIndex) => {+ if (isCurrentLocation) {+ // Load index only if current location+ setIndex(directoryIndex);+ }+ isIndexing.current = undefined;+ forceUpdate();+ return true;+ })+ .catch((err) => {+ isIndexing.current = undefined;+ //lastError.current = err;+ forceUpdate();+ return false;+ });+ });+ }+async function createLocationsIndexes(extractText = true): Promise<boolean> {for (let location of locations) {try {diff --git a/src/renderer/locales/en/core.json b/src/renderer/locales/en/core.jsonindex c1d026ef5..b38b206e3 100644--- a/src/renderer/locales/en/core.json+++ b/src/renderer/locales/en/core.json@@ -978,5 +978,6 @@"importTagsRecursive": "Importing tags recursive","noModelsLoaded": "Error: No AI-models are loaded, please check if the AI-service is running.","fileModified": "File was modified, do you want to save the changes?",+ "indexDisabledConfirm": "Indexing is currently disabled for this location.\nWould you like to force a reindex?","-": "-"}