Skip to content

Commit

Permalink
fix: pasting multiple files #1987 (#2306)
Browse files Browse the repository at this point in the history
  • Loading branch information
agiledev24 committed Feb 20, 2024
1 parent 9693d0d commit 7c6b669
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions packages/desktop/src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,12 +445,15 @@ app.on('ready', async () => {
ipcMain.on('writeTempFile', (event, arg) => {
const temporaryFilesDirectory = path.join(appDataPath, 'temporaryFiles')
fs.mkdirSync(temporaryFilesDirectory, { recursive: true })
const filePath = `${path.join(temporaryFilesDirectory, arg.fileName)}`
const id = `${Date.now()}_${Math.random().toString(36).substring(0, 20)}`
const name = arg.ext ? arg.fileName.split(arg.ext)[0] : arg.fileName
const filePath = `${path.join(temporaryFilesDirectory, `${name}_${id}${arg.ext}`)}`
fs.writeFileSync(filePath, arg.fileBuffer)

event.reply('writeTempFileReply', {
path: filePath,
id: arg.fileName.split(arg.ext)[0],
id,
name,
ext: arg.ext,
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const Channel = () => {
...existingFiles,
[arg.id]: {
ext: arg.ext,
name: arg.id,
name: arg.name,
path: arg.path,
},
}
Expand Down

0 comments on commit 7c6b669

Please sign in to comment.