ConfigMe icon indicating copy to clipboard operation
ConfigMe copied to clipboard

YamlFileResource requires an existing File

Open Sxtanna opened this issue 4 years ago • 0 comments

YamlFileResource#createReader calls YamlFileReader#loadFile which uses Files.newInputStream(path: Path) which will throw a NoSuchFileException if the File at that path does not exist.

SettingsManagerBuilder uses the Utils method Utils.createFileIfNotExists(path: Path) to avoid this scenario: https://github.com/AuthMe/ConfigMe/blob/5f8aa2a4007348efaefbc9a41b740ffb6788bf25/src/main/java/ch/jalu/configme/SettingsManagerBuilder.java#L58

Refactoring this method to return the path, and using it inline here: https://github.com/AuthMe/ConfigMe/blob/5f8aa2a4007348efaefbc9a41b740ffb6788bf25/src/main/java/ch/jalu/configme/resource/YamlFileResource.java#L53

Would probably be the best route for ensuring proper functionality of YamlFileResource as a whole.

Sxtanna avatar Oct 16 '21 19:10 Sxtanna