From afbfd29d66987fce73dbba830b408e3ee3fa37c9 Mon Sep 17 00:00:00 2001 From: Amos Ng Date: Fri, 12 Jun 2020 23:53:21 +0800 Subject: [PATCH] Hotfix to allow for directory creation during migration --- src/main/java/mdnet/cache/DiskLruCache.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/mdnet/cache/DiskLruCache.java b/src/main/java/mdnet/cache/DiskLruCache.java index 5e2715b..91ad816 100644 --- a/src/main/java/mdnet/cache/DiskLruCache.java +++ b/src/main/java/mdnet/cache/DiskLruCache.java @@ -966,6 +966,10 @@ public final class DiskLruCache implements Closeable { // Move files to new caching tree if exists Path oldCache = Paths.get(directory + File.separator + key + "." + i); Path newCache = Paths.get(directory + subKeyPath + File.separator + key + "." + i); + + File newCacheDirectory = new File(directory + subKeyPath, key + "." + i + ".tmp"); + newCacheDirectory.getParentFile().mkdirs(); + if (Files.exists(oldCache)) { try { Files.move(oldCache, newCache, StandardCopyOption.ATOMIC_MOVE); @@ -985,6 +989,10 @@ public final class DiskLruCache implements Closeable { // Move files to new caching tree if exists Path oldCache = Paths.get(directory + File.separator + key + "." + i + ".tmp"); Path newCache = Paths.get(directory + subKeyPath + File.separator + key + "." + i + ".tmp"); + + File newCacheDirectory = new File(directory + subKeyPath, key + "." + i + ".tmp"); + newCacheDirectory.getParentFile().mkdirs(); + if (Files.exists(oldCache)) { try { Files.move(oldCache, newCache, StandardCopyOption.ATOMIC_MOVE);