mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-15 23:06:07 -04:00
Force refreshing version list when remove version from disk
This commit is contained in:
parent
c209617ee7
commit
1956ba7a73
@ -50,9 +50,7 @@ public class Versions {
|
|||||||
isMovingToTrashSupported ? i18n("version.manage.remove.confirm.trash", version, version + "_removed") :
|
isMovingToTrashSupported ? i18n("version.manage.remove.confirm.trash", version, version + "_removed") :
|
||||||
i18n("version.manage.remove.confirm", version);
|
i18n("version.manage.remove.confirm", version);
|
||||||
Controllers.confirmDialog(message, i18n("message.confirm"), () -> {
|
Controllers.confirmDialog(message, i18n("message.confirm"), () -> {
|
||||||
if (profile.getRepository().removeVersionFromDisk(version)) {
|
profile.getRepository().removeVersionFromDisk(version);
|
||||||
profile.getRepository().refreshVersionsAsync().start();
|
|
||||||
}
|
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,25 +166,29 @@ public class DefaultGameRepository implements GameRepository {
|
|||||||
if (!file.renameTo(removedFile))
|
if (!file.renameTo(removedFile))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
versions.remove(id);
|
|
||||||
|
|
||||||
if (FileUtils.isMovingToTrashSupported() && FileUtils.moveToTrash(removedFile)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove json files first to ensure HMCL will not recognize this folder as a valid version.
|
|
||||||
List<File> jsons = FileUtils.listFilesByExtension(removedFile, "json");
|
|
||||||
jsons.forEach(f -> {
|
|
||||||
if (!f.delete())
|
|
||||||
LOG.warning("Unable to delete file " + f);
|
|
||||||
});
|
|
||||||
// remove the version from version list regardless of whether the directory was removed successfully or not.
|
|
||||||
try {
|
try {
|
||||||
FileUtils.deleteDirectory(removedFile);
|
versions.remove(id);
|
||||||
} catch (IOException e) {
|
|
||||||
LOG.log(Level.WARNING, "Unable to remove version folder: " + file, e);
|
if (FileUtils.isMovingToTrashSupported() && FileUtils.moveToTrash(removedFile)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove json files first to ensure HMCL will not recognize this folder as a valid version.
|
||||||
|
List<File> jsons = FileUtils.listFilesByExtension(removedFile, "json");
|
||||||
|
jsons.forEach(f -> {
|
||||||
|
if (!f.delete())
|
||||||
|
LOG.warning("Unable to delete file " + f);
|
||||||
|
});
|
||||||
|
// remove the version from version list regardless of whether the directory was removed successfully or not.
|
||||||
|
try {
|
||||||
|
FileUtils.deleteDirectory(removedFile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOG.log(Level.WARNING, "Unable to remove version folder: " + file, e);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} finally {
|
||||||
|
refreshVersionsAsync().start();
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void refreshVersionsImpl() {
|
protected void refreshVersionsImpl() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user