harshankur / officeParser

A Node.js library to parse text out of any office file. Currently supports docx, pptx, xlsx and odt, odp, ods..
MIT License
123 stars 17 forks source link

Tempfile is not deleted when incorrect file type is given even if preserveTempFiles is false #32

Closed Pascaltib closed 3 months ago

Pascaltib commented 3 months ago
switch(extension) {
                case "docx":
                   ...
                default:
                    throw ERRORMSG.extensionUnsupported(extension);
            }

When the unsupported extension error is thrown it will skip the execution of the internalCallback function which uses rimraf to remove file if preserveTempFiles is false.

I assume this is an oversight.

Thanks for this library your code is very readable and easy to follow <3

harshankur commented 3 months ago

I wouldn't say oversight but probably not wise thinking on my part. I assumed that if an error occurs, the user might want to look at the temp files. However, that's absurd for unsupported extension and the preserveTempFiles flag takes care of the user's preference anyway. Thanks for pointing this out. I will fix it in 4.1.0.