diff options
author | Ian Bull | 2011-03-31 18:06:14 +0000 |
---|---|---|
committer | Ian Bull | 2011-03-31 18:06:14 +0000 |
commit | b58af7a8d2eb1405f783c83b73caf6ed9e88c927 (patch) | |
tree | b3b7eef3dadd1f903488c62aec8598d214fa96a6 /bundles/org.eclipse.equinox.p2.artifact.repository | |
parent | 3982b4e6718cf2dec70d18d934e766b16f2b557a (diff) | |
download | rt.equinox.p2-b58af7a8d2eb1405f783c83b73caf6ed9e88c927.tar.gz rt.equinox.p2-b58af7a8d2eb1405f783c83b73caf6ed9e88c927.tar.xz rt.equinox.p2-b58af7a8d2eb1405f783c83b73caf6ed9e88c927.zip |
NEW - bug 341508: Errors in log when running tests: [Fatal Error] :1:1: Premature end of file.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=341508
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.artifact.repository')
-rw-r--r-- | bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Activator.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Activator.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Activator.java index ffe716f3f..cf9a88288 100644 --- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Activator.java +++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Activator.java @@ -63,12 +63,27 @@ public class Activator implements BundleActivator { } Location anyLoc = (Location) ServiceHelper.getService(Activator.getContext(), Location.class.getName()); File repositoryFile = URIUtil.toFile(repositoryLocation); - Location location = anyLoc.createLocation(null, getLockFile(repositoryLocation).toURL(), !repositoryFile.canWrite()); + Location location = anyLoc.createLocation(null, getLockFile(repositoryLocation).toURL(), isReadOnly(repositoryFile)); location.set(getLockFile(repositoryLocation).toURL(), false); locationCache.put(repositoryLocation, location); return location; } + /** + * Determines if a location is read only by checking the file, and looking + * at the parent chain if necessary. + */ + private boolean isReadOnly(File file) { + if (file == null) + return true; // If we've reached the root, then return true + else if (file.canWrite()) + return false; // If we can write to this area, then it's not read-only + else if (file.exists()) + return true; // if we can't write && file exists, then this is a read only area + else + return isReadOnly(file.getParentFile()); + } + private File getLockFile(URI repositoryLocation) throws IOException { if (!URIUtil.isFileURI(repositoryLocation)) { throw new IOException("Cannot lock a non file based repository"); //$NON-NLS-1$ |