Changeset 13647 in josm for trunk/src/org/openstreetmap/josm/gui/layer
- Timestamp:
- 2018-04-19T20:37:16+02:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/AutosaveTask.java
r13114 r13647 4 4 import static org.openstreetmap.josm.tools.I18n.marktr; 5 5 import static org.openstreetmap.josm.tools.I18n.tr; 6 import static org.openstreetmap.josm.tools.Utils.getSystemProperty; 6 7 7 8 import java.io.BufferedReader; … … 383 384 public List<File> getUnsavedLayersFiles() { 384 385 List<File> result = new ArrayList<>(); 385 File[] files = autosaveDir.listFiles((FileFilter) 386 pathname -> OsmImporter.FILE_FILTER.accept(pathname) || NoteImporter.FILE_FILTER.accept(pathname)); 387 if (files == null) 388 return result; 389 for (File file: files) { 390 if (file.isFile()) { 391 boolean skipFile = false; 392 File pidFile = getPidFile(file); 393 if (pidFile.exists()) { 394 try (BufferedReader reader = Files.newBufferedReader(pidFile.toPath(), StandardCharsets.UTF_8)) { 395 String jvmId = reader.readLine(); 396 if (jvmId != null) { 397 String pid = jvmId.split("@")[0]; 398 skipFile = jvmPerfDataFileExists(pid); 386 try { 387 File[] files = autosaveDir.listFiles((FileFilter) 388 pathname -> OsmImporter.FILE_FILTER.accept(pathname) || NoteImporter.FILE_FILTER.accept(pathname)); 389 if (files == null) 390 return result; 391 for (File file: files) { 392 if (file.isFile()) { 393 boolean skipFile = false; 394 File pidFile = getPidFile(file); 395 if (pidFile.exists()) { 396 try (BufferedReader reader = Files.newBufferedReader(pidFile.toPath(), StandardCharsets.UTF_8)) { 397 String jvmId = reader.readLine(); 398 if (jvmId != null) { 399 String pid = jvmId.split("@")[0]; 400 skipFile = jvmPerfDataFileExists(pid); 401 } 402 } catch (IOException | SecurityException t) { 403 Logging.error(t); 399 404 } 400 } catch (IOException | SecurityException t) {401 Logging.error(t);402 405 } 403 } 404 if (!skipFile) { 405 result.add(file); 406 } 407 } 406 if (!skipFile) { 407 result.add(file); 408 } 409 } 410 } 411 } catch (SecurityException e) { 412 Logging.log(Logging.LEVEL_ERROR, "Unable to list unsaved layers files", e); 408 413 } 409 414 return result; … … 411 416 412 417 private static boolean jvmPerfDataFileExists(final String jvmId) { 413 File jvmDir = new File( System.getProperty("java.io.tmpdir") + File.separator + "hsperfdata_" + System.getProperty("user.name"));418 File jvmDir = new File(getSystemProperty("java.io.tmpdir") + File.separator + "hsperfdata_" + getSystemProperty("user.name")); 414 419 if (jvmDir.exists() && jvmDir.canRead()) { 415 420 File[] files = jvmDir.listFiles((FileFilter) file -> file.getName().equals(jvmId) && file.isFile());
Note:
See TracChangeset
for help on using the changeset viewer.