Bug 252727 - [fiximprove] : Preprocessor creates readonly files in .processed
Summary: [fiximprove] : Preprocessor creates readonly files in .processed
Status: CLOSED WONTFIX
Alias: None
Product: MTJ (Archived)
Classification: Tools
Component: Project Builder (show other bugs)
Version: 0.9   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 1.0   Edit
Assignee: David Marques CLA
QA Contact:
URL:
Whiteboard:
Keywords: core
Depends on:
Blocks:
 
Reported: 2008-10-30 04:57 EDT by Rainer CLA
Modified: 2009-07-09 12:04 EDT (History)
6 users (show)

See Also:
gang_ma: review?


Attachments
Patch with bug resolution (1.94 KB, patch)
2008-12-09 15:56 EST, David Marques CLA
wgp010: iplog+
wgp010: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rainer CLA 2008-10-30 04:57:35 EDT
all files generated in the .processed folder (preprocessor enabled) are readonly (-r--r--r--). Therefore, cleaning the project does not work since MacOSX (probably linux too) does not let you delete readonly files. So if you want to clean a project you have to go to the commandline and sudo "rm -rf .processed" in order to make the project compile again. 

I hope that this is a simple fix but it would greatly improve my efficiency.

thanks
- Rainer
Comment 1 Rainer CLA 2008-10-30 05:15:06 EDT
I believe the problem is in 

PreprocessorBuilder.java

in method

    private void writeProcessedResults(final IResource resource,
            byte[] contents, IProgressMonitor monitor) throws CoreException {

        ...
        outputFile.setCharset("UTF-8", monitor);
        outputFile.setDerived(true);
-->     setReadOnly(outputFile, true);

I am not sure what the motivation for making the file readonly is (probably only Craig knows that), but it causes problems on MacOS.
Comment 2 Diego Madruga Sandin CLA 2008-10-30 10:30:10 EDT
Hi Rainer,

i believe that files generated in the .processed folder are made read-only so the user cannot directly edit the preprocessed code leading to inconsistencies in the generated .class files. 

Maybe the best solution to fix this issue in MacOSX and Linux, is not generating read-write files, but add a contributor to the clean action that can remove this generated files in the .processed folder.

We'll have to investigate this issue and discuss the best approach. 

Craig, do you have any suggestion?

Comment 3 Craig Setera CLA 2008-10-30 10:35:18 EDT
To make sure I understand the circumstances... this is when you invoke the "Clean Project..." action?
Comment 4 Rainer CLA 2008-10-30 11:12:29 EDT
yes, the problem occurs when you try to clean the project. While I can theoretically see the point in trying to prevent the users from messing with these files, I am not sure if it matters really since usually dirs starting with a . are hidden anyway. I have changed the mentioned line to make it read/write and that fixes the problem. But another solution would be to catch the exception in the clean step, make the file writeable and then delete it again (something like a forceDelete).

Comment 5 Craig Setera CLA 2008-10-30 11:16:10 EDT
Actually, the builders that are part of MTJ get a callback method explicitly for a clean operation.  It would be a simple matter of running through the folder hierarchy at that point to remove the read-only attribute.  

Given that the file names are the same as the unprocessed files, I think it is well worthwhile keeping them read-only by default.
Comment 6 Gang(Allen) Ma CLA 2008-10-31 01:01:44 EDT
I think this is a good solution, keep the preprocessed file read-only and do sth in PreprocessorBuilder.clean().

But another problem is: can the preprocess project be deleted sucessfully in MacOSX? I don't have the environment to test it.

(In reply to comment #5)
> Actually, the builders that are part of MTJ get a callback method explicitly
> for a clean operation.  It would be a simple matter of running through the
> folder hierarchy at that point to remove the read-only attribute.  
> Given that the file names are the same as the unprocessed files, I think it is
> well worthwhile keeping them read-only by default.

Comment 7 Craig Setera CLA 2008-11-02 13:33:32 EST
I would assume if the first thing that is done is to set the files and folders to read/write mode that it should be possible to delete on any platform. 

I have a Mac and can test changes.
Comment 8 Markus Keller CLA 2008-11-06 09:02:23 EST
FYI: I just filed bug 254444: "IResource#move(..) and #delete(..) fail on locked files on the Mac".
Comment 9 David Marques CLA 2008-11-17 08:22:38 EST
Hello everyone,

   I will take a look on this issue, and will submit a patch with this issue solved.
Comment 10 David Marques CLA 2008-12-09 15:56:27 EST
Created attachment 119968 [details]
Patch with bug resolution

Hello everyone,

I finally got the time to fix this issue. Follows the patch with the resolution.

[],

David Marques
Comment 11 Craig Setera CLA 2008-12-09 15:59:54 EST
This solution looks solid to me.  I don't have an up to date workspace at the moment to do the commit of the changes.
Comment 12 Diego Madruga Sandin CLA 2008-12-09 16:15:56 EST
I can commit the patch if you have revised it.

(In reply to comment #11)
> This solution looks solid to me.  I don't have an up to date workspace at the
> moment to do the commit of the changes.
> 

Comment 13 Gustavo de Paula CLA 2008-12-10 12:13:47 EST
i'm working on that

:)
gep

(In reply to comment #12)
> I can commit the patch if you have revised it.
> 
> (In reply to comment #11)
> > This solution looks solid to me.  I don't have an up to date workspace at the
> > moment to do the commit of the changes.
> > 
> 

Comment 14 Gustavo de Paula CLA 2008-12-10 12:45:38 EST
Comment on attachment 119968 [details]
Patch with bug resolution

code reviewed and commited to svn
Comment 15 Gustavo de Paula CLA 2008-12-10 12:46:02 EST
done.
Comment 16 Gustavo de Paula CLA 2008-12-30 14:11:10 EST
bug released into 0.9.1
Comment 17 Rainer CLA 2009-01-15 03:13:36 EST
0.9.1 fixes this instance of the problem however, I still have a problem when I am updating from SVN and the file was removed on the server. In this case it looks as if Eclipse tries to delete the preprocessed file which does not work due to the same reason as the initial bug.

I still think that making these files readonly in the first place does more harm than good (at least on macos). Usually the .processed folder is anyway hidden which should be hint enough for people to not mess with these files.

My configuration:
Eclipse 3.4.1
MTJ 0.9.1
Comment 18 Gustavo de Paula CLA 2009-01-21 12:11:32 EST
david, who worked on the previous patch, is on vacation. once he is back i will ask him to take a look at this.

:)
gep

(In reply to comment #17)
> 0.9.1 fixes this instance of the problem however, I still have a problem when I
> am updating from SVN and the file was removed on the server. In this case it
> looks as if Eclipse tries to delete the preprocessed file which does not work
> due to the same reason as the initial bug.
> 
> I still think that making these files readonly in the first place does more
> harm than good (at least on macos). Usually the .processed folder is anyway
> hidden which should be hint enough for people to not mess with these files.
> 
> My configuration:
> Eclipse 3.4.1
> MTJ 0.9.1
> 

Comment 19 Craig Setera CLA 2009-01-22 19:30:20 EST
Read-only files should not have anything to do with SVN.  These files should be (used to be) marked as "Derived" in Eclipse and should never have been checked into SVN in the first place.  The .processed directory is not something that should ever end up in source control.  

The question is whether we are no longer correctly marking these files as derived or if source control was done outside of Eclipse?  If source control was handled outside of Eclipse, this is no longer something that we can do anything about.

I don't believe that we should be switching these to read-write files and believe we have solved the root problem in the last round of development.
Comment 20 Rainer CLA 2009-01-24 01:31:53 EST
I fear there is a misunderstanding. 

Imagine I have a source file src/myclass.java (which is checked into svn) and the preprocessor generates .processed/myclass.java. The arc file is thenk  deleted by someone else. As I update from svn and the src file is deleted eclipse tries to delete .processed/myclass.java. This fails due to the same permission problem. 

Similarily, if I refactor/rename myclass.java to myotherclass.java, the deletion of the old processed file fails. 
Hope that clarifies the issue.  
Comment 21 Rainer CLA 2009-01-24 01:35:38 EST
Ups, my iPhone autocorrection caught me. The "arc" file should obviously mean "src" file. Furthermore I hope that it is obvious that the .processed folder is not checked into svn. 

Btw I use subversive with svnkit (both latest versions) but I don think that this really matters. 
Comment 22 Diego Madruga Sandin CLA 2009-04-29 16:50:31 EDT
I'm moving it to a feature release.
Comment 23 Gustavo de Paula CLA 2009-07-09 10:13:12 EDT
change to wontfix for different reasons: no headcount to do it, no applicable anymore or could not find a good solution to do it
Comment 24 Gustavo de Paula CLA 2009-07-09 10:14:28 EDT
close wontfix bugs