Closed frapontillo closed 5 years ago
Implementation changed in 0224efaef89fd01b8e8c951efaeff7cf3cf4b5da to clean up internal duplicated separators too 💯.
We leave the developer to specify the file path as best as possible. This would only provide some safety around what's been passed, which should be separated with a File.separator
.
Problem
When building a
BatchFile
withLiteBatchFileBuilder
, we were simply checking thatpath
wasn't the file separator/
, so we wouldn't add a duplicated separator after that. But that fix (#475) didn't work for cases where thepath
is something likemy/path/to/the/file/
(with a file separator at the end), so we were essentially still adding a double/
, causing issues like failed downloads.Solution
The solution consists in treating each string we need to concatenate as the same kind of path segment:
storageRoot.path()
) starts with a file separator, we add a file separator to theStringBuilder
StringBuilder
if the last char of theStringBuilder
is not a file separator/
) from the segmentStringBuilder
Tests
Tests have been added to prove that all edge and middle cases are covered for.