Changeset 29946 in osm for applications


Ignore:
Timestamp:
2013-09-23T19:29:35+02:00 (11 years ago)
Author:
akks
Message:

[JOSM_ImageryCache]: correct database cleaning, at last

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/imagerycache/src/org/openstreetmap/josm/plugins/imagerycache/TileDAOMapDB.java

    r29944 r29946  
    6969                storages.put(source, m);
    7070               
    71                 System.out.println("Opened database file successfully: "+f.getAbsolutePath());
     71                Main.info("Opened database file successfully: "+f.getAbsolutePath());
    7272            } catch (Exception ex) {
    73                 System.out.println("Error: can not create database, file: "+f.getAbsolutePath());
     73                Main.warn("Error: can not create database, file: "+f.getAbsolutePath());
    7474                //System.out.println(ex.getMessage());
    7575                ex.printStackTrace();
     
    171171               
    172172                // Merging!
    173                 System.out.println("Moving records from "+f.getName()+" to open storage "+source);
     173                Main.info("Moving records from "+f.getName()+" to open storage "+source);
    174174                myMap.putAll(m);
    175175                db.close();
     
    177177                f.delete();
    178178               
    179                 System.out.println("Moved database successfully from file "+f.getAbsolutePath());
     179                Main.info("Moved database successfully from file "+f.getAbsolutePath());
    180180            } catch (Exception ex) {
    181181                System.out.println(ex.getMessage());
     
    192192        try {
    193193            dbs.get(name).close();
    194             dbs.remove(name);
    195             storages.remove(name);
    196             for (int t=0; t<20; t++) {
    197                 String fname = getDBFileName(name, t);
    198                 File f = new File(cacheFolder, fname);
    199                 if (!f.exists() || !f.canWrite()) continue;
     194        } catch (Exception e) {
     195            Main.warn("Something may be wrong, can not close the database.");
     196        }
     197
     198        dbs.remove(name);
     199        storages.remove(name);
     200        for (int t=0; t<20; t++) {
     201            String fname = getDBFileName(name, t);
     202            File f = new File(cacheFolder, fname);
     203            if (!f.exists() || !f.canWrite()) continue;
     204            f.delete();
     205            f = new File(cacheFolder, fname+".p");
     206            if (!f.exists() || !f.canWrite()) continue;
     207            f.delete();
     208            f = new File(cacheFolder, fname+".lock");
     209            if (!f.exists() || !f.canWrite()) continue;
     210            try {
    200211                f.delete();
    201                 f = new File(cacheFolder, fname+".p");
    202                 if (!f.exists() || !f.canWrite()) continue;
    203                 f.delete();
    204                 f = new File(cacheFolder, fname+".lock");
    205                 if (!f.exists() || !f.canWrite()) continue;
    206                 f.delete();
    207             }
    208         } catch (Exception e) { Main.warn("Can not delete file, maybe it is locvked by another JOSM instance. This is not a serious error then."); }
     212            } catch (Exception e) { Main.warn("Can not delete file, maybe it is locvked by another JOSM instance. This is not a serious error then."); }
     213        }
    209214    }
    210215}
Note: See TracChangeset for help on using the changeset viewer.