Changeset 3559 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2010-09-24T08:50:03+02:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/AutosaveTask.java
r3461 r3559 221 221 File lastFile = info.backupFiles.pollLast(); 222 222 if (lastFile != null) { 223 File backupFile = new File(deletedLayersDir, lastFile.getName()); 224 lastFile.renameTo(backupFile); 225 deletedLayers.add(lastFile); 223 moveToDeletedLayersFolder(lastFile); 226 224 } 227 225 for (File file: info.backupFiles) { 228 226 file.delete(); 229 }230 231 while (deletedLayers.size() > PROP_DELETED_LAYERS.get()) {232 deletedLayers.remove().delete();233 227 } 234 228 } catch (IOException e) { … … 270 264 layerName = layerName.substring(0, layerName.lastIndexOf('.')); 271 265 result.add(new OsmDataLayer(ds, layerName, null)); 272 f.renameTo(new File(deletedLayersDir, f.getName()));266 moveToDeletedLayersFolder(f); 273 267 } catch (FileNotFoundException e) { 274 268 // Should not happen … … 282 276 } 283 277 278 private void moveToDeletedLayersFolder(File f) { 279 File backupFile = new File(deletedLayersDir, f.getName()); 280 if (backupFile.exists()) { 281 deletedLayers.remove(backupFile); 282 backupFile.delete(); 283 } 284 if (f.renameTo(backupFile)) { 285 deletedLayers.add(backupFile); 286 } else { 287 System.err.println(String.format("Warning: Could not move autosaved file %s to %s folder", f.getName(), deletedLayersDir.getName())); 288 f.delete(); 289 } 290 while (deletedLayers.size() > PROP_DELETED_LAYERS.get()) { 291 deletedLayers.remove().delete(); 292 } 293 } 294 284 295 public void dicardUnsavedLayers() { 285 296 for (File f: getUnsavedLayersFiles()) { 286 f.renameTo(new File(deletedLayersDir, f.getName())); 287 } 288 } 289 297 moveToDeletedLayersFolder(f); 298 } 299 } 290 300 }
Note:
See TracChangeset
for help on using the changeset viewer.