aws / aws/aws-sdk-java-v2

TransferManager.downloadDirectory crashes on windows if a key contains colon ':'

Aperta
#3,790 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug p2 transfer-manager
Lingua principale
Java
Stelle
2.6k
Fork
1k
Merge medio
2g 9h
PR unite (30g)
51

Descrizione

### Describe the bug

If the target directory contains an object with a key which contains a colon character, then it throws java.nio.file.InvalidPathException: Illegal char <:>

### Expected Behavior

All files are downloaded, illegal characters are changed to underscore
(Like in the AWS console. If that is an accepted solution there, I believe it should work the same way here too.)

If it unacceptable for some reason, then catch the exception and either skip the file or use the downloadFileRequestTransformer.destination as fileName if provided.

### Current Behavior

Download stops and
java.nio.file.InvalidPathException: Illegal char <:>
is thrown

### Reproduction Steps

download any directory with an object with a colon in it's key

### Possible Solution

In DownloadDirectoryHelper.determineDestinationPath method the java.nio.file.Path.resolve method is used to construct the destination path. If the current fileSystem is windows then it checks for reserved characters before creates the new path.

before calling resolve(relativePath), all reserved characters (<>:\"|?*) should be replaced with underscore.
There is a normalizeKey method there, probably a String.replaceAll there would do the trick.

(probably the same is true on other FileSystems, although I didn't test it on Linux)

### Additional Information/Context

using downloadFileRequestTransformer does NOT help, because the original destination path is always calculated (even if it is replaced later by the transformer). The Exception is thrown when the default destination path is **calculated**, not when the file is **written** to the fileSystem

### AWS Java SDK version used

2.20.8

### JDK version used

17

### Operating System and version

Windows 11

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia da DownloadDirectoryHelper.determineDestinationPath e verifica come viene usato normalizeKey prima di Path.resolve. Riproduci il download di una directory su Windows con una chiave oggetto contenente i due punti, quindi verifica che i caratteri riservati vengano gestiti e che il download venga completato senza InvalidPathException.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
aws, java
Ambito
backend
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.