project-stacker/stacker

Bug: Import different URLs but with same base filename and size results in stacker believing they are the same.

Opened this issue · 2 comments

stacker version

stacker version stacker v0.40.1-e54a685 liblxc a330126b45c7c3b6fcf0f9ba6c1eda7bdb4e508a

Describe the bug

given an import statement such as,
import

In this case, the base filename is the same and files are the same size, but content is different.
However, in pkg/stacker/network.go, in the Download(), we use the path.Base(url), thus in example provided, Download() will find in the cache. Although the hashes are most likely different, but since the sizes are the same, stacker uses the cached copy.

Perhaps should not use the base filename here.

To reproduce

See above.

Seen error:
downloading http://pathtofile/a/file1 1.36 KiB / 1.36 KiB [------------------------------------------------------------------------------------] 100.00% ? p/s
matched content length of http://pathtofile/b/file1, taking a leap of faith and using cached copy

Expected behavior

See above example.

Screenshots

No response

Additional context

No response

smoser commented

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Modified-Since ^ maybe include this

that wouldn't actually help in this scenario.
The problem here is just that stacker considers 'basename' as a world wide unique name in its cache.

the cache just needs to include the full url, doesn't it?