Bugfix/rename request open tab not found (#3192)

* Refactor: Normalize and resolve paths in renameItem action

* Refactor: Normalize and resolve paths in renameItem action (handler side)

* :
This commit is contained in:
Pragadesh-45 2024-09-26 10:15:09 +05:30 committed by GitHub
parent 1f17d39a91
commit a1719a33fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -16,6 +16,7 @@ const {
sanitizeDirectoryName,
isWSLPath,
normalizeWslPath,
normalizeAndResolvePath
} = require('../utils/filesystem');
const { openCollectionDialog } = require('../app/collections');
const { generateUidBasedOnHash, stringifyJson, safeParseJSON, safeStringifyJSON } = require('../utils/common');
@ -329,12 +330,8 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
ipcMain.handle('renderer:rename-item', async (event, oldPath, newPath, newName) => {
try {
// Normalize paths if they are WSL paths
if (isWSLPath(oldPath)) {
oldPath = normalizeWslPath(oldPath);
}
if (isWSLPath(newPath)) {
newPath = normalizeWslPath(newPath);
}
oldPath = isWSLPath(oldPath) ? normalizeWslPath(oldPath) : normalizeAndResolvePath(oldPath);
newPath = isWSLPath(newPath) ? normalizeWslPath(newPath) : normalizeAndResolvePath(newPath);
if (!fs.existsSync(oldPath)) {
throw new Error(`path: ${oldPath} does not exist`);