fix: InvalidPathException when custom run directory is not valid

This commit is contained in:
huanghongxun
2020-04-23 11:13:03 +08:00
parent a3b74e0c75
commit d574d8d78b
2 changed files with 25 additions and 4 deletions

View File

@@ -62,10 +62,16 @@ public class HMCLGameRepository extends DefaultGameRepository {
@Override
public File getRunDirectory(String id) {
switch (getGameDirectoryType(id)) {
case VERSION_FOLDER: return getVersionRoot(id);
case ROOT_FOLDER: return super.getRunDirectory(id);
case CUSTOM: return new File(getVersionSetting(id).getGameDir());
default: throw new Error();
case VERSION_FOLDER:
return getVersionRoot(id);
case ROOT_FOLDER:
return super.getRunDirectory(id);
case CUSTOM:
File dir = new File(getVersionSetting(id).getGameDir());
if (!FileUtils.isValidPath(dir)) return getVersionRoot(id);
return dir;
default:
throw new Error();
}
}