monument icon indicating copy to clipboard operation
monument copied to clipboard

`DOWNLOADS` cache ignores the destination file, causing issue if mulitple download operations use a same download url

Open Fallen-Breath opened this issue 1 year ago • 0 comments

https://github.com/skyrising/monument/blob/a29e1a80860dd2515db761e516c3507796ebee0c/src/main/kotlin/de/skyrising/guardian/gen/files.kt#L17-L21

Issue at: DOWNLOADS.computeIfAbsent(url) ignores the file parameter

To reproduce

  1. Define a branch container both mc 1.20.3 and mc 1.20.4, using mojang mapping
  2. Run the monument

Expected behavior

Both mc 1.20.3 and mc 1.20.4 have their mojang mapping.txt downloaded successfully

Actual behavior

Only the first download attempts to the mapping.txt will succeed

Reason: mc1.20.3 and mc1.20.4 use the same mapping.txt, causing the issue that the later download attempt will be skipped (due to the computeIfAbsent) call

More information on the same server_mappings and client_mappings:

  • https://github.com/skyrising/mc-versions/blob/351a09651cc4c8019a7d46c956b55369e6e5675e/data/version/1.20.3.json#L4-L25
  • https://github.com/skyrising/mc-versions/blob/351a09651cc4c8019a7d46c956b55369e6e5675e/data/version/1.20.4.json#L4-L24

Example fix

private val DOWNLOADS = ConcurrentHashMap<Pair<URI, Path>, CompletableFuture<Unit>>()

Fallen-Breath avatar Dec 12 '24 18:12 Fallen-Breath