diff options
| author | Thomas Watson | 2014-03-07 21:33:36 +0000 |
|---|---|---|
| committer | Thomas Watson | 2014-03-10 13:24:14 +0000 |
| commit | 180bc899f1560e348940b0e981ba115a5904da7c (patch) | |
| tree | d57d0dde3b7356c4eed4ffe3c17993f02141ab83 | |
| parent | 82e8bb282bf520275f22cfa6001809cbbe46884e (diff) | |
| download | rt.equinox.framework-180bc899f1560e348940b0e981ba115a5904da7c.tar.gz rt.equinox.framework-180bc899f1560e348940b0e981ba115a5904da7c.tar.xz rt.equinox.framework-180bc899f1560e348940b0e981ba115a5904da7c.zip | |
Bug 429921 - consistency issues with extracting bundle content to cache
- Fix usage of mkdirs()
5 files changed, 14 insertions, 11 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/location/BasicLocation.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/location/BasicLocation.java index 9427d947c..2272e1c86 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/location/BasicLocation.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/location/BasicLocation.java @@ -163,10 +163,11 @@ public class BasicLocation implements Location { if (isLocked()) return false; File parentFile = new File(lock.getParent()); - if (!parentFile.exists()) - if (!parentFile.mkdirs()) + if (!parentFile.isDirectory()) { + parentFile.mkdirs(); + if (!parentFile.isDirectory()) throw new IOException(NLS.bind(Msg.location_folderReadOnly, parentFile)); - + } setLocker(lock); if (locker == null) return true; diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java index f9cc617f3..4f03e86d5 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java @@ -404,7 +404,7 @@ public final class BundleInfo { public File getDataFile(String path) { File dataRoot = getStorage().getFile(getBundleId() + "/" + Storage.BUNDLE_DATA_DIR, false); //$NON-NLS-1$ - if (!Storage.secureAction.exists(dataRoot) && (storage.isReadOnly() || !Storage.secureAction.mkdirs(dataRoot))) { + if (!Storage.secureAction.isDirectory(dataRoot) && (storage.isReadOnly() || !(Storage.secureAction.mkdirs(dataRoot) || Storage.secureAction.isDirectory(dataRoot)))) { if (getStorage().getConfiguration().getDebug().DEBUG_GENERAL) Debug.println("Unable to create bundle data directory: " + dataRoot.getAbsolutePath()); //$NON-NLS-1$ return null; diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java index 0a689877b..3795f5dd4 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java @@ -758,7 +758,8 @@ public class Storage { File contentFile; if (!isReference) { File generationRoot = new File(childRoot, bundleID + "/" + generationID); //$NON-NLS-1$ - if (!generationRoot.mkdirs()) { + generationRoot.mkdirs(); + if (!generationRoot.isDirectory()) { throw new BundleException("Could not create generation directory: " + generationRoot.getAbsolutePath()); //$NON-NLS-1$ } contentFile = new File(generationRoot, BUNDLE_FILE_NAME); @@ -1682,7 +1683,7 @@ public class Storage { } break; } - if (!bundleTempDir.exists()) { + if (!bundleTempDir.isDirectory()) { bundleTempDir.mkdirs(); bundleTempDir.deleteOnExit(); // This is just a safeguard incase the VM is terminated unexpectantly, it also looks like deleteOnExit cannot really work because diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/ZipBundleFile.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/ZipBundleFile.java index 5c4640258..05a96cc9a 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/ZipBundleFile.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/ZipBundleFile.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2013 IBM Corporation and others. + * Copyright (c) 2005, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -171,7 +171,8 @@ public class ZipBundleFile extends BundleFile { extractDirectory(zipEntry.getName()); } else { if (zipEntry.getName().endsWith("/")) { //$NON-NLS-1$ - if (!nested.mkdirs()) { + nested.mkdirs(); + if (!nested.isDirectory()) { if (debug.DEBUG_GENERAL) Debug.println("Unable to create directory: " + nested.getPath()); //$NON-NLS-1$ throw new IOException(NLS.bind(Msg.ADAPTOR_DIRECTORY_CREATE_EXCEPTION, nested.getAbsolutePath())); @@ -186,7 +187,7 @@ public class ZipBundleFile extends BundleFile { Debug.println("Creating file: " + nested.getPath()); //$NON-NLS-1$ /* create the necessary directories */ File dir = new File(nested.getParent()); - if (!dir.exists() && !dir.mkdirs()) { + if (!dir.mkdirs() && !dir.isDirectory()) { if (debug.DEBUG_GENERAL) Debug.println("Unable to create directory: " + dir.getPath()); //$NON-NLS-1$ throw new IOException(NLS.bind(Msg.ADAPTOR_DIRECTORY_CREATE_EXCEPTION, dir.getAbsolutePath())); diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/storagemanager/StorageManager.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/storagemanager/StorageManager.java index 7ddfe4c5b..d7d2b193a 100644 --- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/storagemanager/StorageManager.java +++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/storagemanager/StorageManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2013 IBM Corporation and others. + * Copyright (c) 2004, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -694,7 +694,7 @@ public final class StorageManager { public void open(boolean wait) throws IOException { if (!readOnly) { managerRoot.mkdirs(); - if (!managerRoot.exists()) + if (!managerRoot.isDirectory()) throw new IOException(Msg.fileManager_cannotLock); if (openCleanup) cleanup(true); |
