Skip to content

Commit fb96675

Browse files
author
jantje
committed
Remove old version when upgrading
1 parent 43d9c6d commit fb96675

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

io.sloeber.core/src/io/sloeber/core/api/LibraryManager.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public LibraryTree() {
142142
.append(library.getArchitectures().toString()).append("\n\n") //$NON-NLS-1$
143143
.append(library.getSentence());
144144
lib = new Library(category, library.getName(), libraryIndex.getName(), builder.toString());
145-
category.libraries.put(library.getName() + " (" + libraryIndex.getName() + ")", lib); //$NON-NLS-1$//$NON-NLS-2$
145+
category.libraries.put(library.getName() + " (" + libraryIndex.getName() + ")", lib); //$NON-NLS-1$//$NON-NLS-2$
146146
}
147147
lib.versions.add(new VersionNumber(library.getVersion()));
148148
if (library.isInstalled()) {
@@ -219,10 +219,19 @@ public static String getPrivateLibraryPathsString() {
219219
return InstancePreferences.getPrivateLibraryPathsString();
220220
}
221221

222+
/**
223+
* Wrapper method for Manager. installAllLatestLibraries(String category)
224+
*
225+
* @param category
226+
*/
222227
public static void installAllLatestLibraries(String category) {
223228
Manager.installAllLatestLibraries(category);
224229
}
225230

231+
/**
232+
* Convenience method for installAllLatestLibraries(String category) calling
233+
* it for all categories
234+
*/
226235
public static void installAllLatestLibraries() {
227236
Set<String> allcategories = getAllCategories();
228237
for (String categorieName : allcategories) {
@@ -231,6 +240,12 @@ public static void installAllLatestLibraries() {
231240

232241
}
233242

243+
/**
244+
* get all the categories for all libraries (installed or not)
245+
*
246+
* @return a list of all the categories that exist in any library json file
247+
* known by sloeber
248+
*/
234249
public static Set<String> getAllCategories() {
235250

236251
Set<String> ret = new TreeSet<>();

io.sloeber.core/src/io/sloeber/core/managers/Manager.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,12 +859,23 @@ public static void onlyKeepLatestPlatforms() {
859859
}
860860
}
861861

862+
/**
863+
* Install the latest version of all the libraries belonging to this
864+
* category If a earlier version is installed this version will be removed
865+
* before installation of the newer version
866+
*
867+
* @param category
868+
*/
862869
public static void installAllLatestLibraries(String category) {
863870
List<LibraryIndex> libraryIndices1 = getLibraryIndices();
864871
for (LibraryIndex libraryIndex : libraryIndices1) {
865872
Collection<Library> libraries = libraryIndex.getLatestLibraries(category);
866873
for (Library library : libraries) {
867874
if (!library.isInstalled()) {
875+
Library previousVersion = libraryIndex.getInstalledLibrary(library.getName());
876+
if (previousVersion != null) {
877+
previousVersion.remove(new NullProgressMonitor());
878+
}
868879
library.install(new NullProgressMonitor());
869880
}
870881
}

0 commit comments

Comments
 (0)