Skip to content

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

fix: Renaming files containing Arabic or Cyrillic letters is broken on AWS (#1387)

Stanimird1b96f0eeae3
diff --git a/app/perspectives/grid-perspective/components/MainContainer.tsx b/app/perspectives/grid-perspective/components/MainContainer.tsx
index 994608c77..309f339cf 100644
--- a/app/perspectives/grid-perspective/components/MainContainer.tsx
+++ b/app/perspectives/grid-perspective/components/MainContainer.tsx
@@ -457,6 +457,8 @@ const GridPerspective = (props: Props) => {
...selectedEntries.filter(entry => entry.uuid !== fsEntry.uuid),
fsEntry
]);
+ } else {
+ props.setSelectedEntries([fsEntry]);
}
setFileContextMenuAnchorEl(event.currentTarget);
// selectedEntry.current = fsEntry;
diff --git a/app/reducers/app.ts b/app/reducers/app.ts
index 91c8d4eb7..3e1853360 100644
--- a/app/reducers/app.ts
+++ b/app/reducers/app.ts
@@ -1792,7 +1792,8 @@ export const actions = {
dispatch: (actions: Object) => void
) =>
PlatformIO.renameFilePromise(filePath, newFilePath)
- .then(() => {
+ .then(result => {
+ const newFilePathFromPromise = result[1];
console.info('File renamed ' + filePath + ' to ' + newFilePath);
dispatch(
actions.showNotification(
@@ -1801,7 +1802,7 @@ export const actions = {
true
)
);
- dispatch(actions.reflectRenameEntry(filePath, newFilePath));
+ dispatch(actions.reflectRenameEntry(filePath, newFilePathFromPromise));
// Update sidecar file and thumb
renameFilesPromise([
[
diff --git a/app/services/objectstore-io.ts b/app/services/objectstore-io.ts
index ecb9765b1..408c443cc 100644
--- a/app/services/objectstore-io.ts
+++ b/app/services/objectstore-io.ts
@@ -26,8 +26,7 @@ import {
normalizePath,
getThumbFileLocationForFile,
getMetaFileLocationForFile,
- extractFileExtension,
- cleanTrailingDirSeparator
+ extractFileExtension
} from '-/utils/paths';
import { FileSystemEntry } from '-/services/utils-io';
@@ -85,7 +84,12 @@ export default class ObjectStoreIO {
Key: path,
Expires: expirationInSeconds
};
- return this.objectStore.getSignedUrl('getObject', params);
+ try {
+ return this.objectStore.getSignedUrl('getObject', params);
+ } catch (e) {
+ console.warn('Error by getSignedUrl' + e.toString());
+ return '';
+ }
};
quitApp = (): void => {
@@ -689,7 +693,7 @@ export default class ObjectStoreIO {
return this.objectStore
.copyObject({
Bucket: this.config.bucketName,
- CopySource: this.config.bucketName + '/' + nFilePath,
+ CopySource: encodeURI(this.config.bucketName + '/' + nFilePath),
Key: nNewFilePath
})
.promise();
@@ -711,28 +715,31 @@ export default class ObjectStoreIO {
});
}
// Copy the object to a new location
- return this.objectStore
- .copyObject({
- Bucket: this.config.bucketName,
- CopySource: this.config.bucketName + '/' + nFilePath, // this.encodeS3URI(nFilePath),
- Key: nNewFilePath
- })
- .promise()
- .then(() =>
- // Delete the old object
- this.objectStore
- .deleteObject({
- Bucket: this.config.bucketName,
- Key: nFilePath
- })
- .promise()
- )
- .catch(e => {
- console.log(e);
- return new Promise((resolve, reject) => {
+ return new Promise((resolve, reject) => {
+ this.objectStore
+ .copyObject({
+ Bucket: this.config.bucketName,
+ CopySource: encodeURI(this.config.bucketName + '/' + nFilePath), // this.encodeS3URI(nFilePath),
+ Key: nNewFilePath
+ })
+ .promise()
+ .then(() =>
+ // Delete the old object
+ this.objectStore
+ .deleteObject({
+ Bucket: this.config.bucketName,
+ Key: nFilePath
+ })
+ .promise()
+ .then(() => {
+ resolve([filePath, nNewFilePath]);
+ })
+ )
+ .catch(e => {
+ console.log(e);
reject('Renaming file failed' + e.code);
});
- });
+ });
};
/**
diff --git a/app/services/platform-io.ts b/app/services/platform-io.ts
index 650f88ef7..450d778e7 100644
--- a/app/services/platform-io.ts
+++ b/app/services/platform-io.ts
@@ -118,12 +118,13 @@ export default class PlatformIO {
static getUserHomePath = (): string => nativeAPI.getUserHomePath();
- static getURLforPath = (path: string): string => {
+ static getURLforPath = (
+ path: string,
+ expirationInSeconds?: number
+ ): string => {
if (objectStoreAPI) {
- return objectStoreAPI.getURLforPath(path);
+ return objectStoreAPI.getURLforPath(path, expirationInSeconds);
}
- // console.log('getURLforPath not supported');
- // return path;
};
static createDirectoryTree = (directoryPath: string): Object =>
@@ -236,7 +237,11 @@ export default class PlatformIO {
newFilePath: string
): Promise<any> => {
if (objectStoreAPI) {
- return objectStoreAPI.renameFilePromise(filePath, newFilePath);
+ return objectStoreAPI
+ .renameFilePromise(filePath, newFilePath)
+ .then(result => {
+ return result;
+ });
}
PlatformIO.ignoreByWatcher(filePath, newFilePath);
diff --git a/app/services/search.ts b/app/services/search.ts
index 7607b868a..11ff4b2b0 100644
--- a/app/services/search.ts
+++ b/app/services/search.ts
@@ -110,11 +110,10 @@ export type SearchQuery = {
const fuseOptions = {
shouldSort: true,
- threshold: 0.3,
+ threshold: 0.4,
location: 0,
distance: 100,
tokenize: true,
- maxPatternLength: 32,
minMatchCharLength: 1,
keys: [
{
diff --git a/package.json b/package.json
index ad5762e8c..bfbb93eaf 100644
--- a/package.json
+++ b/package.json
@@ -260,7 +260,7 @@
"exif-js": "^2.3.0",
"file-saver": "^2.0.5",
"fs-extra": "^9.0.1",
- "fuse.js": "^6.4.3",
+ "fuse.js": "^6.4.6",
"geolocation-utils": "^1.2.3",
"html2canvas": "^1.0.0-alpha.12",
"i18next": "^11.3.3",
diff --git a/yarn.lock b/yarn.lock
index 623c2d21c..d764d8bcf 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -9317,10 +9317,10 @@ functions-have-names@^1.2.0:
resolved "https://registry.yarnpkg.com/functions-have-names/-/functions-have-names-1.2.1.tgz#a981ac397fa0c9964551402cdc5533d7a4d52f91"
integrity sha512-j48B/ZI7VKs3sgeI2cZp7WXWmZXu7Iq5pl5/vptV5N2mq+DGFuS/ulaDjtaoLpYzuD6u8UgrUKHfgo7fDTSiBA==
-fuse.js@^6.4.3:
- version "6.4.3"
- resolved "https://registry.yarnpkg.com/fuse.js/-/fuse.js-6.4.3.tgz#aadd6ac34aab5b1d6e6c60462fcb4d1c3f53bb01"
- integrity sha512-JNgngolukIrqwayWnvy6NLH63hmwKPhm63o0uyBg51jPD0j09IvAzlV1rTXfAsgxpghI7khAo6Mv+EmvjDWXig==
+fuse.js@^6.4.6:
+ version "6.4.6"
+ resolved "https://registry.yarnpkg.com/fuse.js/-/fuse.js-6.4.6.tgz#62f216c110e5aa22486aff20be7896d19a059b79"
+ integrity sha512-/gYxR/0VpXmWSfZOIPS3rWwU8SHgsRTwWuXhyb2O6s7aRuVtHtxCkR33bNYu3wyLyNx/Wpv0vU7FZy8Vj53VNw==
g-status@^2.0.2:
version "2.0.2"