-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle duplicate files #183
base: master
Are you sure you want to change the base?
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/hack4impact/3dp4me/D1FB6JAxg1e7adxbasPURNu1ERX3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff, just some small changes
Does this current version work locally for you. I'm running this locally and it doesn't seem to handle more than 1 duplicate file |
It looks like uploading a duplicated filename doesn't trigger a POST request to upload the file |
hmm seems to work for me locally. i upload a file, hit save, then upload the file again. |
wait, it only works when i shuffle between tabs before uploading each subsequent file. the post request is only triggered the first time after i hit the tab, then doesn't trigger when i try uploading more files unless i switch to another tab then switch back ^hm this only happens when I try uploading the same file but works fine for any other file lemme take a look |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments, great work, Gene :D
var updatedFileName = filename; | ||
var file = ''; | ||
var suffix = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use let
here
file = filename.split('.')[0]; | ||
suffix = '.' + filename.split('.')[1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work for files with multiple .
like .styles.js
maybe use lastIndexOf()
and substring to split around the last .
file = filename; | ||
} | ||
if (data.filter((e) => e.filename === filename).length > 0) { | ||
var numPrev = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let
:)
} else { | ||
file = filename; | ||
} | ||
if (data.filter((e) => e.filename === filename).length > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use if (data.some())
instead of filter
since it's much clearer
const modifiedFileName = await modifyFileName( | ||
fileName, | ||
stepData[fieldKey], | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I were looking at this without context, i wouldnt understand what this function does. Think a one line comment explaining what this function does would be super helpful!
Also this is the library i found: https://www.npmjs.com/package/uniquefilename |
764275a
to
a7a4f5f
Compare
Status:
🚀 Ready
Description
Handles duplicate file uploads by appending subscripts.
Fixes #59
Todos