Skip to content

Commit

Permalink
Bot: attempt to create autosave folder if it does not exist (#12751)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanVanAtta authored Jul 23, 2024
1 parent bc4c018 commit e84286e
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ public class AutoSaveFileUtils {
/** Returns a list path objects representing each auto save file. */
public static List<Path> getAutoSavePaths() {
var autoSaveFolder = ClientSetting.saveGamesFolderPath.getValueOrThrow().resolve("autoSave");

if (!Files.exists(autoSaveFolder)) {
try {
Files.createDirectories(autoSaveFolder);
} catch (IOException e) {
throw new RuntimeException(
"Autosave folder did not exist, was not able to create it. Required folder: "
+ autoSaveFolder.toAbsolutePath(),
e);
}
}

try (Stream<Path> paths = Files.list(autoSaveFolder)) {
return paths.filter(f -> !Files.isDirectory(f)).collect(Collectors.toList());
} catch (IOException e) {
Expand Down

0 comments on commit e84286e

Please sign in to comment.