spotify / XCRemoteCache

Other
830 stars 53 forks source link

Do not change dependencies order when remapping overlay #85

Closed polac24 closed 2 years ago

polac24 commented 2 years ago

Do not sort the dependencies list in OverlayDependenciesRemapper.

71 introduced a remapper that reads virtual file system overlay file (vfsoverlay) and based on that, computes a fingerprint based on disk files that the vfs defines.

It contained an optimization that gets rid of all duplicated dependencies (if vfsoverlay defined a mapping that remaps a path to a disk file path that is already in a dependency list). Implementation detail: it was implemented as the simplest Set+sorting.

Even this makes sense for a producer side (the meta json file could be smaller), it has a damaging result on the consumer side. If a list of files is reordered on a consumer side (comparing the order that the producer mode observed), the file fingerprint will not match. With hindsight, I think it was a premature optimization and the simplest solution is to just map every single dependency in order both for consumer and producer modes.

Fixes #84 and #80.