Skip to content

Commit

Permalink
only rename if file does not already exist #6
Browse files Browse the repository at this point in the history
  • Loading branch information
mifi committed Nov 3, 2020
1 parent 4d8cbe0 commit ccc3e79
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ module.exports = ({ sharedPath: sharedPathIn, port, maxUploadSize, zipCompressio

await pMap(files, async (file) => {
try {
await fs.rename(file.path, join(sharedPath, filenamify(file.name)));
const targetPath = join(sharedPath, filenamify(file.name));
if (!(await fs.pathExists(targetPath))) await fs.rename(file.path, targetPath);
} catch (err) {
console.error(`Failed to rename ${file.name}`, err);
}
Expand Down

0 comments on commit ccc3e79

Please sign in to comment.