TagSpaces is an offline, open source, document manager with tagging support
Add switch for enable link extraction during location indexing (#2312)
Stanimir201f7140c1c1
diff --git a/src/renderer/components/dialogs/CreateEditLocationDialog.tsx b/src/renderer/components/dialogs/CreateEditLocationDialog.tsxindex 675dcf2d0..51e87ad53 100644--- a/src/renderer/components/dialogs/CreateEditLocationDialog.tsx+++ b/src/renderer/components/dialogs/CreateEditLocationDialog.tsx@@ -182,6 +182,9 @@ function CreateEditLocationDialog(props: Props) {const [fullTextIndex, setFullTextIndex] = useState<boolean>(selectedLocation ? selectedLocation.fullTextIndex : false,);+ const [extractLinks, setExtractLinks] = useState<boolean>(+ selectedLocation ? selectedLocation.extractLinks : false,+ );const [accessKeyId, setAccessKeyId] = useState<string>(selectedLocation ? selectedLocation.accessKeyId : '',);@@ -409,6 +412,7 @@ function CreateEditLocationDialog(props: Props) {reloadOnFocus,disableThumbnailGeneration,fullTextIndex,+ extractLinks,watchForChanges,maxIndexAge,ignorePatternPaths,@@ -430,6 +434,7 @@ function CreateEditLocationDialog(props: Props) {reloadOnFocus,disableThumbnailGeneration,fullTextIndex,+ extractLinks,watchForChanges,maxIndexAge,ignorePatternPaths,@@ -455,6 +460,7 @@ function CreateEditLocationDialog(props: Props) {reloadOnFocus,disableThumbnailGeneration,fullTextIndex,+ extractLinks,watchForChanges: false,maxIndexAge,maxLoops,@@ -733,6 +739,29 @@ function CreateEditLocationDialog(props: Props) {</>}/>+ {fullTextIndex && (+ <FormControlLabel+ labelPlacement="start"+ style={{ justifyContent: 'space-between', marginLeft: 0 }}+ control={+ <Switch+ disabled={!Pro}+ data-tid="extractLinksTID"+ name="extractLinks"+ checked={extractLinks}+ onChange={(event: ChangeEvent<HTMLInputElement>) => {+ setExtractLinks(event.target.checked);+ }}+ />+ }+ label={+ <>+ {t('core:extractLinks')}+ {Pro ? <BetaLabel /> : <ProLabel />}+ </>+ }+ />+ )}{isFullTextIndexConfirmDialogOpened && selectedLocation && (<ConfirmDialogopen={isFullTextIndexConfirmDialogOpened}diff --git a/src/renderer/hooks/LocationIndexContextProvider.tsx b/src/renderer/hooks/LocationIndexContextProvider.tsxindex b696d016c..832d1ecce 100644--- a/src/renderer/hooks/LocationIndexContextProvider.tsx+++ b/src/renderer/hooks/LocationIndexContextProvider.tsx@@ -362,7 +362,12 @@ export const LocationIndexContextProvider = ({) {// Start indexing in worker if not in the object store modereturn loc- .createDirectoryIndexInWorker(dirPath, extractText, ignorePatterns)+ .createDirectoryIndexInWorker(+ dirPath,+ extractText,+ !!loc.extractLinks,+ ignorePatterns,+ ).then((result) => {if (result && result.success) {return loadIndexFromDisk(dirPath, param.locationID);@@ -407,7 +412,9 @@ export const LocationIndexContextProvider = ({const mode = ['extractThumbPath'];if (extractText) {mode.push('extractTextContent');- mode.push('extractLinks');+ if (loc.extractLinks) {+ mode.push('extractLinks');+ }}return createIndex({diff --git a/src/renderer/locales/en/core.json b/src/renderer/locales/en/core.jsonindex 5f4154d8a..991a3666f 100644--- a/src/renderer/locales/en/core.json+++ b/src/renderer/locales/en/core.json@@ -405,6 +405,7 @@"disableIndexing": "Disable Indexing","disableThumbnailGeneration": "Disable Thumbnail Generation","createFullTextIndex": "Enable full text search",+ "extractLinks": "Extract links","watchForChangesInLocation": "Watch for external changes in this location","collectedTags": "Collected Tags","pauseResumePlayback": "Pause/Resume Playback",diff --git a/src/renderer/services/utils-io.ts b/src/renderer/services/utils-io.tsindex 25b8e0ecd..75632b721 100644--- a/src/renderer/services/utils-io.ts+++ b/src/renderer/services/utils-io.ts@@ -1205,6 +1205,7 @@ export function toTsLocation(location: CommonLocation): TS.S3Location {disableThumbnailGeneration: location.disableThumbnailGeneration,}),...(location.fullTextIndex && { fullTextIndex: location.fullTextIndex }),+ ...(location.extractLinks && { extractLinks: location.extractLinks }),...(location.maxIndexAge && { maxIndexAge: location.maxIndexAge }),...(location.maxLoops && { maxLoops: location.maxLoops }),...(location.persistTagsInSidecarFile && {diff --git a/src/renderer/tagspaces.namespace.d.ts b/src/renderer/tagspaces.namespace.d.tsindex 66157f025..fc3290b90 100644--- a/src/renderer/tagspaces.namespace.d.ts+++ b/src/renderer/tagspaces.namespace.d.ts@@ -42,6 +42,7 @@ export namespace TS {reloadOnFocus?: boolean;disableThumbnailGeneration?: boolean;fullTextIndex?: boolean;+ extractLinks?: boolean;maxIndexAge?: number;maxLoops?: number;persistTagsInSidecarFile?: boolean;diff --git a/src/renderer/utils/CommonLocation.ts b/src/renderer/utils/CommonLocation.tsindex 0c1d00b0c..2a252f600 100644--- a/src/renderer/utils/CommonLocation.ts+++ b/src/renderer/utils/CommonLocation.ts@@ -42,6 +42,7 @@ export class CommonLocation implements TS.Location {reloadOnFocus?: boolean;disableThumbnailGeneration?: boolean;fullTextIndex?: boolean;+ extractLinks?: boolean;maxIndexAge?: number;maxLoops?: number;persistTagsInSidecarFile?: boolean;@@ -81,6 +82,7 @@ export class CommonLocation implements TS.Location {this.reloadOnFocus = location.reloadOnFocus;this.disableThumbnailGeneration = location.disableThumbnailGeneration;this.fullTextIndex = Pro && location.fullTextIndex;+ this.extractLinks = Pro && location.extractLinks;this.maxIndexAge = location.maxIndexAge;this.maxLoops = location.maxLoops;this.persistTagsInSidecarFile = location.persistTagsInSidecarFile;@@ -943,6 +945,7 @@ export class CommonLocation implements TS.Location {createDirectoryIndexInWorker = (directoryPath: string,extractText: boolean,+ extractLinks: boolean,ignorePatterns: Array<string>,): Promise<any> => {/*if (this.isReadOnly) {@@ -956,6 +959,7 @@ export class CommonLocation implements TS.Location {const payload = JSON.stringify({directoryPath,extractText,+ extractLinks,ignorePatterns,});return window.electronIO.ipcRenderer.invoke(