Ignore:
Timestamp:
2009-11-30T13:48:36+01:00 (14 years ago)
Author:
stoecker
Message:

fix #4047 - update warning does not disappear

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/plugins/PluginDownloader.java

    r2542 r2554  
    106106    public static int downloadDescription() {
    107107        int count = 0;
     108        LinkedList<String> sitenames = new LinkedList<String>();
    108109        for (String site : getSites()) {
    109             /* TODO: remove old site files (everything except .jar) */
    110110            try {
     111                String filesite = site.replaceAll("%<(.*)>", "");
    111112                /* replace %<x> with empty string or x=plugins (separated with comma) */
    112113                String pl = Main.pref.getCollectionAsString("plugins");
     
    114115                    site = site.replaceAll("%<(.*)>", "$1"+pl);
    115116                else
    116                     site = site.replaceAll("%<(.*)>", "");
     117                    site = filesite;
    117118                BufferedReader r = new BufferedReader(new InputStreamReader(new URL(site).openStream(), "utf-8"));
    118119                new File(Main.pref.getPreferencesDir()+"plugins").mkdir();
     120                String sname = count + "-site-" + filesite.replaceAll("[/:\\\\ <>|]", "_") + ".txt";
     121                sitenames.add(sname);
    119122                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"));
    122124                for (String line = r.readLine(); line != null; line = r.readLine()) {
    123125                    out.append(line+"\n");
     
    127129                count++;
    128130            } 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                }
    129155            }
    130156        }
Note: See TracChangeset for help on using the changeset viewer.