Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 25662

Summary: [resources] File.create in read-only directory should set more specific error code
Product: [Eclipse Project] Platform Reporter: Knut Radloff <knut_radloff>
Component: ResourcesAssignee: Rafael Chaves <eclipse>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: dj.houghton, n.a.edgar
Version: 2.0   
Target Milestone: 2.1 M3   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Knut Radloff CLA 2002-11-01 17:06:17 EST
build 20021018

Creating a file in a read-only directory on Linux currently fails with an error code 
FAILED_READ_LOCAL. Other than the fact that this should be 
FAILED_WRITE_LOCAL (see bug 25658) the error code and message could be 
more specific.
The method that is throwing the exception could easily test if the target or the  
target's parent (the latter only on some platforms, like Linux) is read-only and set a 
more precise error message and status code. This would save clients from testing 
for read-only folders. See bug 3043 for the related platform UI issue.
Comment 1 DJ Houghton CLA 2002-11-08 16:54:52 EST
I don't like the idea if writing a file fails, then call #isReadOnly on all of 
its parents up the hierarchy. This could potentially be a very costly operation 
since it involves going to the file system for each call and the file system is 
not necessarily local in all cases.

Adding NE to CC for comment.
Comment 2 Nick Edgar CLA 2002-11-09 13:06:54 EST
If Core does not want to do this, then this should be closed as WONTFIX, and 
we can add the check at the UI level.  While Core doesn't want to incur this 
expense for every file write, it's not unreasonable for the UI to do this just 
for the case of manually creating a new file (bug 3043).
Comment 3 DJ Houghton CLA 2002-11-11 09:55:48 EST
Marking as WONTFIX.
Comment 4 Knut Radloff CLA 2002-11-11 13:55:53 EST
You don't have to walk up the hierarchy. Creating a file only fails on Linux 
when the immediate parent is read-only. You only have to check the immediate 
parent folder.
Is that still too expensive for core to support? It would save clients that 
display the error message a lot of trouble.
Comment 5 DJ Houghton CLA 2002-11-11 22:42:01 EST
Re-opening for consideration.
Comment 6 DJ Houghton CLA 2002-11-11 23:12:09 EST
Ok, I can do that. As long as we don't come back later with a file system which 
requires us to walk the whole hierarchy up to the root. :-)

Fixed and released into HEAD.

Added new error constant IResourceStatus.PARENT_READ_ONLY.
Message is: "Parent of file: {0} is marked as read-only.".
Comment 7 Knut Radloff CLA 2002-11-19 18:55:07 EST
Naturally I'd like the same improved error reporting when creating a folder 
within a read-only folder.
Comment 8 DJ Houghton CLA 2002-11-19 21:24:56 EST
Oops, sorry.

Code should go in/around FileSystemStore.writeFolder().
Need to write appropriate test case as well.


Comment 9 Rafael Chaves CLA 2002-11-21 12:25:55 EST
Fixed, tested and released into HEAD.