Bug 21606 - ImageBuilder deletes & adds rather than overwriting
Summary: ImageBuilder deletes & adds rather than overwriting
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: Other other
: P3 normal (vote)
Target Milestone: 2.0.1   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-07-15 19:49 EDT by Jed Anderson CLA
Modified: 2002-09-20 09:25 EDT (History)
1 user (show)

See Also:


Attachments
A possible fix in Eclipse patch format. (patch.txt) (85.50 KB, patch)
2002-07-15 19:50 EDT, Jed Anderson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jed Anderson CLA 2002-07-15 19:49:00 EDT
Build: Eclipse 2.0

The AbstractImageBuilder together with the IncrementalImageBuilder 
deletes and creates a class file rather than overwriting the existing one.  This causes one extra 
OS call per class file.  It also makes it hard for VCMs which track changes in the filesystem to 
maintain history (I'm not sure this always makes sense for class files... but it could).
Comment 1 Jed Anderson CLA 2002-07-15 19:50:09 EDT
Created attachment 1699 [details]
A possible fix in Eclipse patch format. (patch.txt)
Comment 2 Jed Anderson CLA 2002-07-16 14:41:06 EDT
See also http://bugs.eclipse.org/bugs/show_bug.cgi?id=20036
Comment 3 Kent Johnson CLA 2002-07-16 15:07:12 EDT
Thanks Jed...

Rearranged the writeClassFile code so the IncrementalImageBuilder can control 
how the bytes are written.

Your change removed the delete but added an exists check for the batch builder.
Comment 4 Jed Anderson CLA 2002-07-16 15:14:56 EDT
excellent.  glad you caught the stuff i missed.
Comment 5 Jed Anderson CLA 2002-07-16 15:43:40 EDT
Just thought of something...

What if the class files get marked read-only?  (VCMs like to futz 
the read-only bit)  Then the setContents call will fail, this could potentially be very unhappy.
Comment 6 Kent Johnson CLA 2002-07-16 16:22:34 EDT
But deleting them first is just as unhappy.

'We' control the class files... if they get tagged as read-only then that's a 
bug in the VCM which they would have to 'fix'.

Ok?
Comment 7 Jed Anderson CLA 2002-07-16 16:28:52 EDT
No, IFile.delete happily deletes read-only files (like a fool).

This means 
that

IFile.delete(...)
IFile.create(...)

has different behaviour 
that

IFile.setContents(...)

when read-only files are introduced into the mix.
Comment 8 Kent Johnson CLA 2002-07-16 16:32:14 EDT
Fine but I still thinks its a VCM bug for them to tag class files which are not 
under version control as read-only.
Comment 9 Kent Johnson CLA 2002-07-16 16:44:34 EDT
Actually I just checked with DJ and delete does whatever the platform does... 
which on Windows means it will fail if the file is tagged read-only.

I think this change will give us the same behavior as we had before...
Comment 10 Jed Anderson CLA 2002-07-16 18:02:26 EDT
I agree with marking this fixed, as VCMs shouldn't be so dumb as to try an version control derived 
files.

However, two more points:
1. Relying on platform specific implementations sounds 
bug prone.
2. I just stepped through the code, and Windows lets you delete read-only files.  I will 
notify DJ of this behaviour.
Comment 11 Nick Edgar CLA 2002-07-25 16:04:32 EDT
Just came across this PR and noticed that the patch file looks like it's 
removing and re-adding the whole contents of the affected files.
How big was the actual change?  Could indicate a bug in compare.
Comment 12 Andre Weinand CLA 2002-07-26 03:46:31 EDT
I don't think its a bug in Compare: patch files are generated by CVS; the Compare plugin 
only applies the patch.
Comment 13 Nick Edgar CLA 2002-07-29 12:49:53 EDT
Andre is correct, we call out to the CVS server to generate them.  I haven't 
seen this -- I would need to know the steps taken to produce it.  Its possible 
there was an EOL issue so all lines looked different to the diff?

Other than asking the server to generate them, there's not much that we do 
that's interesting here.
Comment 14 Jerome Lanneluc CLA 2002-08-19 12:15:22 EDT
Verified by stepping through the code.
Comment 15 David Audel CLA 2002-08-21 04:37:32 EDT
Verified.
Comment 16 David Audel CLA 2002-09-20 09:25:07 EDT
Verified in 2.1 M1