public void unloadAndDelete(SmallModuleEntry sme) { UploaderPlugin up; synchronized (this) { up = sme.up; sme.up = null; // deactivate initiated here if (up == null) { Path zipPath = UploaderPlugin.getLocalPath(updateLocation, sme); if (Files.exists(zipPath)) { try { Files.delete(zipPath); } catch (Exception a) { System.out.println("could not delete unactive plugin " + sme.getName()); } } return; } } try { up.destroy(); } catch (Exception a) { System.out.println("could not destory plugin " + sme.getName()); a.printStackTrace(); } }
public void initIndex() throws Exception { try { Files.createDirectories(updateLocation); } catch (Exception a) { // ignore } long startUpdate = System.currentTimeMillis(); System.out.println("fetching updates "); updateIndex(); long span = System.currentTimeMillis() - startUpdate; System.out.println("done updates index - time taken = " + span); i = new Index(updateLocation.resolve("index.json")); LinkedList<Runnable> updateOperations = new LinkedList<>(); for (SmallModuleEntry sme : i.getSmallModuleEntrys()) { LocallyPresent locallyPresent = UploaderPlugin.locallyPresent(updateLocation, sme); if (locallyPresent != LocallyPresent.ABSENT) { if (sme.isDead()) { deleteLocal(sme); // dead plugins get cleaned. :D } else { updateOperations.add(loadInNewThread(sme)); } } } ReactiveThread rt = ReactiveThread.create( CompletionCallback.DUMMY, "Updating all plugins", updateOperations.toArray(new Runnable[updateOperations.size()])); rt.setDaemon(true); rt.start(); }
private void deleteLocal(SmallModuleEntry sme) { Path localCopyPath = UploaderPlugin.getLocalPath(updateLocation, sme); try { Files.deleteIfExists(localCopyPath); } catch (IOException a) { a.printStackTrace(); } }