tomvlk / node-split-file

:seedling: NodeJS Module to split and merge files for several purposes like transporting over unstable networks.
MIT License
41 stars 13 forks source link

function splitFileBySize problem #18

Closed popzadid closed 7 years ago

popzadid commented 7 years ago

This functions not will work correctly please changing a variable like this

var allparts = parts+1; for (var i = 0; i < allparts; i ++) { partInfo[i] = { number: i + 1, start: i * splitSize, end: (i * splitSize) + splitSize }; if (i === (allparts - 1)) { partInfo[i].end = (i * splitSize) + lastSplitSize; } } thank you

tomvlk commented 7 years ago

Hello @popzadid , Could you please provide me more context about the problem? Eventually a test case with the input you have when it doesn't work.

popzadid commented 7 years ago

In functions splitFile.splitFileBySize(path, size)

am input Filesize = 19524568 byte and splitsize is 5242880 byte

after using functions i printed partInfo it's show

[ { number: 1, start: 0, end: 5242880 }, { number: 2, start: 5242880, end: 10485760 }, { number: 3, start: 10485760, end: 14281688 } ]

but It's wrong results because in your iteration 'for (var i = 0; i < parts ; i++)' is your not add last part to split.

tomvlk commented 7 years ago

This issue has been fixed in 2.1.0.