Changeset 2554 in josm for trunk/src/org/openstreetmap/josm/plugins/PluginDownloader.java
- Timestamp:
- 2009-11-30T13:48:36+01:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/plugins/PluginDownloader.java
r2542 r2554 106 106 public static int downloadDescription() { 107 107 int count = 0; 108 LinkedList<String> sitenames = new LinkedList<String>(); 108 109 for (String site : getSites()) { 109 /* TODO: remove old site files (everything except .jar) */110 110 try { 111 String filesite = site.replaceAll("%<(.*)>", ""); 111 112 /* replace %<x> with empty string or x=plugins (separated with comma) */ 112 113 String pl = Main.pref.getCollectionAsString("plugins"); … … 114 115 site = site.replaceAll("%<(.*)>", "$1"+pl); 115 116 else 116 site = site.replaceAll("%<(.*)>", "");117 site = filesite; 117 118 BufferedReader r = new BufferedReader(new InputStreamReader(new URL(site).openStream(), "utf-8")); 118 119 new File(Main.pref.getPreferencesDir()+"plugins").mkdir(); 120 String sname = count + "-site-" + filesite.replaceAll("[/:\\\\ <>|]", "_") + ".txt"; 121 sitenames.add(sname); 119 122 BufferedWriter out = new BufferedWriter(new OutputStreamWriter( 120 new FileOutputStream(new File(Main.pref.getPluginsDirFile(), 121 count + "-site-" + site.replaceAll("[/:\\\\ <>|]", "_") + ".txt")), "utf-8")); 123 new FileOutputStream(new File(Main.pref.getPluginsDirFile(), sname)), "utf-8")); 122 124 for (String line = r.readLine(); line != null; line = r.readLine()) { 123 125 out.append(line+"\n"); … … 127 129 count++; 128 130 } catch (IOException x) { 131 } 132 } 133 /* remove old files */ 134 File[] pluginFiles = Main.pref.getPluginsDirFile().listFiles(); 135 if (pluginFiles != null) { 136 for (File f : pluginFiles) { 137 if (!f.isFile()) 138 continue; 139 String fname = f.getName(); 140 if(fname.endsWith(".jar")) 141 { 142 for(String s : PluginHandler.oldplugins) 143 { 144 if(fname.equals(s+".jar")) 145 { 146 System.out.println(tr("Delete old plugin {0}",fname)); 147 f.delete(); 148 } 149 } 150 } 151 else if(!fname.endsWith(".jar.new") && !sitenames.contains(fname)) 152 { 153 System.out.println(tr("Delete old plugin file {0}",fname)); 154 } 129 155 } 130 156 }
Note:
See TracChangeset
for help on using the changeset viewer.