Hotfix to allow for directory creation during migration

This commit is contained in:
Amos Ng 2020-06-12 23:53:21 +08:00
parent 5090443b7a
commit afbfd29d66
No known key found for this signature in database
GPG key ID: 89086414F634D123

View file

@ -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);