DownloadableFileSource shouldn't use url in cache-key

Summary

I have many large and small files as remote sources. After changing URLs to mirrors, which I know provides the same file with same contents, BuildStream considers this RESOLVED instead of CACHED, mostly because this line:

https://gitlab.com/BuildStream/buildstream/blob/ce91ce5d2eb73295d1862aa8514e631b6231300e/buildstream/plugins/sources/_downloadablefilesource.py#L95

Because it builds the mirror directory via this logic:

    def _get_mirror_dir(self):
        return os.path.join(self.get_mirror_directory(),
                            utils.url_directory_name(self.original_url))

    def _get_mirror_file(self, sha=None):
        return os.path.join(self._get_mirror_dir(), sha or self.ref)

I expected BuildStream to use file's content only for such work.

Steps to reproduce

One can create a remote source, fetch it, and then change the url :.

What is the current bug behavior?

What is the expected correct behavior?

Relevant logs and/or screenshots

Possible fixes

Maybe we can consider changing _get_mirror_dir and get_unique_key and removing urls role there.

Other relevant information

  • BuildStream version affected: /milestone %BuildStream_v1.x