Skip to content

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

search fixes - add listDirectory mode (#1525)

Stanimir128cb596b443
diff --git a/app/components/DirectoryTreeView.tsx b/app/components/DirectoryTreeView.tsx
index cb083a6ca..c5662c62d 100644
--- a/app/components/DirectoryTreeView.tsx
+++ b/app/components/DirectoryTreeView.tsx
@@ -251,7 +251,7 @@ const DirectoryTreeView = forwardRef(
const getDirectoriesTree = (subFolder: SubFolder, deepLevel: number) =>
// const { settings } = getState();
- PlatformIO.listDirectoryPromise(subFolder.path, true)
+ PlatformIO.listDirectoryPromise(subFolder.path, [])
// @ts-ignore
.then(dirEntries => {
if (dirEntries !== undefined) {
diff --git a/app/package-template.json b/app/package-template.json
index 1e420a1f2..25a0fb3df 100644
--- a/app/package-template.json
+++ b/app/package-template.json
@@ -5,6 +5,6 @@
"nodeDependencies": {
"@tagspaces/extensions": "1.0.4",
"sharp": "^0.29.2",
- "@tagspaces/tagspaces-ws": "^1.0.18"
+ "@tagspaces/tagspaces-ws": "^1.0.22"
}
}
diff --git a/app/package.json b/app/package.json
index ae0f005b2..88dc06740 100644
--- a/app/package.json
+++ b/app/package.json
@@ -13,8 +13,8 @@
"license": "AGPL-3.0",
"scripts": {},
"dependencies": {
- "@tagspaces/extensions": "1.0.3",
- "@tagspaces/tagspaces-ws": "^1.0.18",
- "sharp": "^0.29.2"
+ "@tagspaces/extensions": "1.0.4",
+ "sharp": "^0.29.2",
+ "@tagspaces/tagspaces-ws": "^1.0.22"
}
}
diff --git a/app/reducers/app.ts b/app/reducers/app.ts
index 4e593701a..179bc66ed 100644
--- a/app/reducers/app.ts
+++ b/app/reducers/app.ts
@@ -925,8 +925,7 @@ export const actions = {
);
PlatformIO.listDirectoryPromise(
directoryPath,
- false,
- true,
+ ['extractThumbPath', 'extractThumbURL'],
currentLocation ? currentLocation.ignorePatternPaths : []
)
.then(results => {
diff --git a/app/services/cordova-io.ts b/app/services/cordova-io.ts
index cc4c96817..cad254544 100644
--- a/app/services/cordova-io.ts
+++ b/app/services/cordova-io.ts
@@ -504,10 +504,13 @@ export default class CordovaIO {
/**
* Creates a list with containing the files and the sub directories of a given directory
*/
- listDirectoryPromise = (path: string, lite: boolean): Promise<any> =>
+ listDirectoryPromise = (
+ path: string,
+ mode = ['extractThumbPath']
+ ): Promise<any> =>
new Promise(async (resolve, reject) => {
console.time('listDirectoryPromise');
- const metaContent = !lite
+ const metaContent = mode.includes('extractThumbPath')
? await this.listMetaDirectoryPromise(path)
: [];
@@ -539,7 +542,7 @@ export default class CordovaIO {
});
}
- if (!lite) {
+ if (mode.includes('extractThumbPath')) {
if (entry.isDirectory) {
// Read tsm.json from subfolders
if (
diff --git a/app/services/electron-io.ts b/app/services/electron-io.ts
index fc457ce83..72f084665 100644
--- a/app/services/electron-io.ts
+++ b/app/services/electron-io.ts
@@ -326,10 +326,15 @@ export default class ElectronIO {
reject('Worker window not available!');
} */
+ /**
+ * @param path
+ * @param mode = ['extractTextContent', 'extractThumbPath']
+ * @param ignorePatterns
+ * @param showIgnored
+ */
listDirectoryPromise = (
path: string,
- lite: boolean = true,
- extractTextContent: boolean = false,
+ mode = ['extractThumbPath'],
ignorePatterns: Array<string> = [],
showIgnored: boolean = true
): Promise<Array<Object>> =>
@@ -403,7 +408,7 @@ export default class ElectronIO {
}
// Read tsm.json from sub folders
- if (!eentry.isFile && !lite) {
+ if (!eentry.isFile && mode.includes('extractThumbPath')) {
const folderMetaPath =
eentry.path +
AppConfig.dirSeparator +
@@ -465,7 +470,7 @@ export default class ElectronIO {
});
// Read the .ts meta content
- if (!lite && containsMetaFolder) {
+ if (containsMetaFolder && mode.includes('extractThumbPath')) {
metaFolderPath = getMetaDirectoryPath(path, AppConfig.dirSeparator);
this.fs.readdir(metaFolderPath, (err, metaEntries) => {
if (err) {
diff --git a/app/services/platform-io.ts b/app/services/platform-io.ts
index ed0da1206..32c2a069a 100644
--- a/app/services/platform-io.ts
+++ b/app/services/platform-io.ts
@@ -183,14 +183,12 @@ export default class PlatformIO {
/**
* Promise === undefined on error
* @param path
- * @param lite
- * @param extractText
+ * @param mode = ['extractTextContent', 'extractThumbPath']
* @param ignorePatterns
*/
static listDirectoryPromise = (
path: string,
- lite: boolean = true,
- extractText: boolean = true,
+ mode = ['extractThumbPath'],
ignorePatterns: Array<string> = []
): Promise<Array<any>> => {
if (objectStoreAPI) {
@@ -198,33 +196,17 @@ export default class PlatformIO {
path,
bucketName: objectStoreAPI.config().bucketName
};
- return PlatformIO.listObjectStoreDir(
- param,
- lite,
- extractText,
- ignorePatterns
- );
+ return PlatformIO.listObjectStoreDir(param, mode, ignorePatterns);
}
- return nativeAPI.listDirectoryPromise(
- path,
- lite,
- extractText,
- ignorePatterns
- );
+ return nativeAPI.listDirectoryPromise(path, mode, ignorePatterns);
};
static listObjectStoreDir = (
param: Object,
- lite: boolean = true,
- extractText: boolean = true,
+ mode = ['extractThumbPath'],
ignorePatterns: Array<string> = []
): Promise<Array<any>> =>
- objectStoreAPI.listDirectoryPromise(
- param,
- lite,
- extractText,
- ignorePatterns
- );
+ objectStoreAPI.listDirectoryPromise(param, mode, ignorePatterns);
static getPropertiesPromise = (path: string): Promise<any> => {
if (objectStoreAPI) {
diff --git a/app/services/utils-io.ts b/app/services/utils-io.ts
index 6d11c8144..fb69942de 100644
--- a/app/services/utils-io.ts
+++ b/app/services/utils-io.ts
@@ -506,7 +506,7 @@ export function createDirectoryIndex(
return createIndex(
param,
- extractText,
+ ['extractThumbPath'],
ignorePatterns,
listDirectoryPromise,
loadTextFilePromise
@@ -541,11 +541,10 @@ export function walkDirectory(
skipDotHiddenFolder: false,
skipDotHiddenFiles: false,
loadMetaDate: true,
- extractText: false,
...options
};
return (
- PlatformIO.listDirectoryPromise(path, false, mergedOptions.extractText)
+ PlatformIO.listDirectoryPromise(path, [])
// @ts-ignore
.then(entries => {
if (window.walkCanceled || entries === undefined) {
@@ -705,7 +704,7 @@ export async function loadSubFolders(
path: string,
loadHidden: boolean = false
) {
- const folderContent = await PlatformIO.listDirectoryPromise(path, true);
+ const folderContent = await PlatformIO.listDirectoryPromise(path, []); // 'extractThumbPath']);
const subfolders = [];
let i = 0;
let isHidden = false;
diff --git a/package.json b/package.json
index e627e0b33..871f80431 100644
--- a/package.json
+++ b/package.json
@@ -152,7 +152,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.50",
+ "@tagspaces/tagspaces-platforms": "^1.0.53",
"aws-amplify": "^3.3.27",
"aws-sdk": "^2.984.0",
"babel-polyfill": "^6.26.0",
diff --git a/yarn.lock b/yarn.lock
index f076ef6de..8f91761cd 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3362,10 +3362,10 @@
dependencies:
defer-to-connect "^1.0.1"
-"@tagspaces/tagspaces-platforms@^1.0.50":
- version "1.0.50"
- resolved "https://registry.yarnpkg.com/@tagspaces/tagspaces-platforms/-/tagspaces-platforms-1.0.50.tgz#5c6686405b6d7e290c3a70d9dafb8916d13f8566"
- integrity sha512-i3f2ltz+q0o/yD9uBvCpgRjpauH3LOyyAtsLWW4rhOxKoY061C/0t0B4HF5zWuZXc+xI2iVYVNberYR+rxHFDQ==
+"@tagspaces/tagspaces-platforms@^1.0.53":
+ version "1.0.53"
+ resolved "https://registry.yarnpkg.com/@tagspaces/tagspaces-platforms/-/tagspaces-platforms-1.0.53.tgz#ac4aedf48d042c6e7e760d327b1efa6b2218e43c"
+ integrity sha512-6N5K5msBYiQsav2Qsy6meqMGezfPvWj2ezH7NgVzkgMQbLeuP40RSPN0vbmOFCSufb39L01KTx8y0dCwqq6HQg==
"@testim/chrome-version@^1.0.7":
version "1.0.7"