Ticket #13171: patch-fix-unable-to-delte-file-message.patch

File patch-fix-unable-to-delte-file-message.patch, 1.7 KB (added by michael2402, 8 years ago)
  • src/org/openstreetmap/josm/data/cache/JCSCacheManager.java

    diff --git a/src/org/openstreetmap/josm/data/cache/JCSCacheManager.java b/src/org/openstreetmap/josm/data/cache/JCSCacheManager.java
    index 260c35e..d127f45 100644
    a b public final class JCSCacheManager {  
    240240    }
    241241
    242242    private static void deleteCacheFiles(String basePathPart) {
    243         Utils.deleteFile(new File(basePathPart + ".key"));
    244         Utils.deleteFile(new File(basePathPart + ".data"));
     243        Utils.deleteFileIfExists(new File(basePathPart + ".key"));
     244        Utils.deleteFileIfExists(new File(basePathPart + ".data"));
    245245    }
    246246
    247247    private static CompositeCacheAttributes getCacheAttributes(int maxMemoryElements) {
  • src/org/openstreetmap/josm/tools/Utils.java

    diff --git a/src/org/openstreetmap/josm/tools/Utils.java b/src/org/openstreetmap/josm/tools/Utils.java
    index bc151aa..6c194d1 100644
    a b public final class Utils {  
    491491    }
    492492
    493493    /**
     494     * Deletes a file and log a default warning if the file exists but the deletion fails.
     495     * @param file file to delete
     496     * @return {@code true} if and only if the file does not exist or is successfully deleted; {@code false} otherwise
     497     * @since xxx
     498     */
     499    public static boolean deleteFileIfExists(File file) {
     500        if (file.exists()) {
     501            return deleteFile(file);
     502        } else {
     503            return true;
     504        }
     505    }
     506
     507    /**
    494508     * Deletes a file and log a default warning if the deletion fails.
    495509     * @param file file to delete
    496510     * @return {@code true} if and only if the file is successfully deleted; {@code false} otherwise