Skip to content
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

Fix issue where we were matching file names poorly for deletion. #1

Merged
merged 1 commit into from
Feb 17, 2018
Merged

Conversation

benirose
Copy link

We had issues when deleting existing files, where one report in the folder had the same name as another but with a bit more tacked on (e.g "Incident Report" and "Incident Report - Old"). If the report for the shorter name generated second, it would delete the report with the longer name because it matched the name using the old code below:
if (fileName.substring(0, options.name.length) === options.name)
This changes the name matching to use the filename instead, removing the datetime and extension before matching:
if (fileName.slice(0, 0-'_YYYY-MM-DD_HH-mm-ss.csv'.length) === options.name)
I could have just use slice(0,-24), but I used the string length for explicitness of what we were slicing off.

Copy link
Member

@mkopinsky mkopinsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for contributing.

@mkopinsky mkopinsky merged commit 11c0fd9 into waytohealth:master Feb 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants