Community
Participate
Working Groups
org.eclipse.equinox.internal.p2.artifact.repository.Activator.isReadOnly(File) is a method to determines the given file whether is read-only, then create the read-only Location instances based on its checking result. For example, the file is UNC style that is read-only shared by another Windows machine, say as \\windows_host\myshare\. There are several Java bugs[1][2] reported File.canWrite()/canRead()/canExecute() have problems on Windows. NIO API FileChannel.tryLock should work. Or refer to how Locker does. [1] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6368018 [2] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6203387
This may be the cause for some of the reported problems relating to the p2 backup/restore functionality as well. (Have not actually scanned that logic to check how it determines what can / can't be done with the files, but would not be surprised if it makes use of File.canRead()/canWrite()).
(In reply to comment #1) > be surprised if it makes use of File.canRead()/canWrite()). be surprised if it does *not* make use of ....
Created attachment 208477 [details] a proposed patch I don't find better way without creating a temporary file for testing. Does everyone have better solution to check whether new files can be created under a specified folder?
No, I think that's the best option. Doing a search returns a couple of other places in our code where we try and create a temp file to determine if a location is readonly. org.eclipse.core.internal.runtime.auth.AuthorizationDatabase#canWrite org.eclipse.osgi.internal.baseadaptor.AdaptorUtil#canWrite Check out the code for the second one, it has special considerations for DLLs on certain Windows-based file systems. Not sure if we need that or not in the p2 code.
(In reply to comment #4) > org.eclipse.core.internal.runtime.auth.AuthorizationDatabase#canWrite > org.eclipse.osgi.internal.baseadaptor.AdaptorUtil#canWrite > > Check out the code for the second one, it has special considerations for DLLs on > certain Windows-based file systems. Not sure if we need that or not in the p2 > code. If Eclipse is installed into "Program Files" by user on Windows 7, the instance of this Eclipse always is read-only when user launches it in normal way. The base Eclipse should not be locked and updated when user launches Eclipse without administrative permission. Fixed, http://git.eclipse.org/c/equinox/rt.equinox.p2.git/commit/?id=4174108261eddcb3cd45006d5f1f7631e4a2a2d9