Skip to content

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

add locationId to GlobalSearch.index items

sytolkd78c7eb8f7c8
diff --git a/app/components/menus/LocationContextMenu.tsx b/app/components/menus/LocationContextMenu.tsx
index 670ad593b..9d88b193d 100644
--- a/app/components/menus/LocationContextMenu.tsx
+++ b/app/components/menus/LocationContextMenu.tsx
@@ -46,7 +46,8 @@ interface Props {
createDirectoryIndex: (
path: string,
fullTextIndex: boolean,
- isCurrentLocation: boolean
+ isCurrentLocation: boolean,
+ locationID: string
) => void;
selectedLocation: TS.Location;
isCurrentLocation: (uuid: string) => boolean;
@@ -75,7 +76,8 @@ const LocationContextMenu = (props: Props) => {
createDirectoryIndex(
getLocationPath(selectedLocation),
selectedLocation.fullTextIndex,
- isCurrentLocation
+ isCurrentLocation,
+ selectedLocation.uuid
);
return true;
})
@@ -87,7 +89,8 @@ const LocationContextMenu = (props: Props) => {
createDirectoryIndex(
getLocationPath(selectedLocation),
selectedLocation.fullTextIndex,
- isCurrentLocation
+ isCurrentLocation,
+ selectedLocation.uuid
);
}
};
diff --git a/app/package.json b/app/package.json
index bf55e0ae1..57403c98f 100644
--- a/app/package.json
+++ b/app/package.json
@@ -15,6 +15,6 @@
"dependencies": {
"@tagspaces/extensions": "1.0.0",
"sharp": "^0.28.3",
- "@tagspaces/tagspaces-ws": "^1.0.6"
+ "@tagspaces/tagspaces-ws": "^1.0.8"
}
}
diff --git a/app/reducers/location-index.ts b/app/reducers/location-index.ts
index 7091ee9d5..229827fe8 100644
--- a/app/reducers/location-index.ts
+++ b/app/reducers/location-index.ts
@@ -187,10 +187,15 @@ export const actions = {
directoryPath: string,
extractText: boolean,
isCurrentLocation: boolean = true,
+ locationID: string = undefined,
ignorePatterns: Array<string> = []
) => (dispatch: (actions: Object) => void) => {
dispatch(actions.startDirectoryIndexing());
- createDirectoryIndex(directoryPath, extractText, ignorePatterns)
+ createDirectoryIndex(
+ { path: directoryPath, locationID },
+ extractText,
+ ignorePatterns
+ )
.then(directoryIndex => {
if (isCurrentLocation) {
// Load index only if current location
@@ -218,10 +223,14 @@ export const actions = {
dispatch(actions.startDirectoryIndexing());
const allLocations = getLocations(state);
- const promises = allLocations.map(location => {
+ const promises = allLocations.map((location: TS.Location) => {
const nextPath = getLocationPath(location);
return (
- createDirectoryIndex(nextPath, extractText, location.ignorePatternPaths)
+ createDirectoryIndex(
+ { path: nextPath, location: location.uuid },
+ extractText,
+ location.ignorePatternPaths
+ )
/* .then(directoryIndex => {
if (Pro && Pro.Indexer) {
Pro.Indexer.persistIndex(
@@ -347,6 +356,7 @@ export const actions = {
GlobalSearch.index = await createDirectoryIndex(
{
path: currentPath,
+ locationID: currentLocation.uuid,
...(isCloudLocation && { bucketName: currentLocation.bucketName })
},
currentLocation.fullTextIndex,
@@ -361,7 +371,10 @@ export const actions = {
!GlobalSearch.index ||
GlobalSearch.index.length === 0
) {
- GlobalSearch.index = await loadIndex(getLocationPath(currentLocation));
+ GlobalSearch.index = await loadIndex({
+ path: getLocationPath(currentLocation),
+ locationID: currentLocation.uuid
+ });
}
Search.searchLocationIndex(GlobalSearch.index, searchQuery)
.then(searchResults => {
@@ -459,6 +472,7 @@ export const actions = {
directoryIndex = await createDirectoryIndex(
{
path: nextPath,
+ locationID: location.uuid,
...(isCloudLocation && { bucketName: location.bucketName })
},
location.fullTextIndex,
@@ -475,7 +489,7 @@ export const actions = {
// if (Pro && Pro.Indexer && Pro.Indexer.loadIndex) {
console.log('Loading index for : ' + nextPath);
directoryIndex = await loadIndex(
- nextPath,
+ { path: nextPath, locationID: location.uuid },
PlatformIO.getDirSeparator()
);
}
diff --git a/app/services/utils-io.ts b/app/services/utils-io.ts
index da5d638bc..0b5218e64 100644
--- a/app/services/utils-io.ts
+++ b/app/services/utils-io.ts
@@ -443,8 +443,10 @@ export function createDirectoryIndex(
// disableIndexing = true
): Promise<Array<TS.FileSystemEntry>> {
let directoryPath;
+ let locationID;
if (typeof param === 'object' && param !== null) {
directoryPath = param.path;
+ ({locationID} = param);
} else {
directoryPath = param;
}
@@ -457,7 +459,7 @@ export function createDirectoryIndex(
ignorePatterns
).then(succeeded => {
if (succeeded) {
- return loadIndex(dirPath);
+ return loadIndex({ path: dirPath, locationID });
}
return undefined;
});
@@ -468,7 +470,7 @@ export function createDirectoryIndex(
persistIndex(param, directoryIndex).then(success => {
if (success) {
console.log('Index generated in folder: ' + directoryPath);
- return enhanceDirectoryIndex(dirPath, directoryIndex);
+ return enhanceDirectoryIndex(dirPath, directoryIndex, locationID);
}
return undefined;
})
diff --git a/package.json b/package.json
index dca53bae7..a3b9ec48b 100644
--- a/package.json
+++ b/package.json
@@ -285,7 +285,7 @@
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.57",
"@material-ui/pickers": "^3.2.10",
- "@tagspaces/tagspaces-platforms": "^1.0.7",
+ "@tagspaces/tagspaces-platforms": "^1.0.9",
"aws-amplify": "^3.3.27",
"aws-sdk": "^2.984.0",
"babel-polyfill": "^6.26.0",
diff --git a/yarn.lock b/yarn.lock
index c3c05d77b..574851afa 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3362,10 +3362,10 @@
dependencies:
defer-to-connect "^1.0.1"
-"@tagspaces/tagspaces-platforms@^1.0.7":
- version "1.0.7"
- resolved "https://registry.yarnpkg.com/@tagspaces/tagspaces-platforms/-/tagspaces-platforms-1.0.7.tgz#fcab0652da31cfde658dbafb1937478e6d7a9e3b"
- integrity sha512-mecmweaYxs7OycSuYVTmiHalHTO+lSdJQZMDBNF+rXPs1OXx1kNsZY63C8pSdh+xYFkG+5nMWZED7q1PbD14+A==
+"@tagspaces/tagspaces-platforms@^1.0.9":
+ version "1.0.9"
+ resolved "https://registry.yarnpkg.com/@tagspaces/tagspaces-platforms/-/tagspaces-platforms-1.0.9.tgz#e06881421e222fe839c3b9a44d3958ea60a63f4c"
+ integrity sha512-vW9wPHYmVWKmYIKexDiMts1boKyr93XYERYGBD7wYJLzNXiF9axA3+X453gDUx+ZMWS/D0ycKiEXxMa6JLsPnA==
"@testim/chrome-version@^1.0.7":
version "1.0.7"