Skip to content

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

fix copy files change meta id (#2178)

Stanimirc18fb4f82989
diff --git a/src/renderer/hooks/IOActionsContextProvider.tsx b/src/renderer/hooks/IOActionsContextProvider.tsx
index 19f35dca3..6e15ee0d8 100644
--- a/src/renderer/hooks/IOActionsContextProvider.tsx
+++ b/src/renderer/hooks/IOActionsContextProvider.tsx
@@ -774,6 +774,16 @@ export const IOActionsContextProvider = ({
false,
)
.then(() => {
+ paths.map((path) => {
+ const location = findLocation(locationID);
+ const targetFilePath =
+ normalizePath(targetPath) +
+ (location
+ ? location.getDirSeparator()
+ : AppConfig.dirSeparator) +
+ extractFileName(path, location?.getDirSeparator());
+ setFileMetaId(locationID, targetFilePath, getUuid());
+ });
console.log('Copy meta and thumbs successful');
return true;
})
@@ -791,6 +801,21 @@ export const IOActionsContextProvider = ({
});
}
+ function setFileMetaId(locationID: string, path: string, fileId: string) {
+ const location = findLocation(locationID);
+ location
+ .loadMetaDataPromise(path)
+ .then((fsEntryMeta: TS.FileSystemEntryMeta) => {
+ if (fsEntryMeta.id) {
+ return saveFsEntryMeta(location.toFsEntry(path, fsEntryMeta.isFile), {
+ ...fsEntryMeta,
+ id: fileId,
+ });
+ }
+ })
+ .catch(() => {});
+ }
+
function fetchUrl(url: string, targetPath: string, haveProgress: boolean) {
if (AppConfig.isElectron) {
return window.electronIO.ipcRenderer.invoke(