Issue with deletion of a file and refresh [message #327333] |
Tue, 15 April 2008 12:47  |
Eclipse User |
|
|
|
Originally posted by: hkumar.agrawal.gmail.com
Hi,
We have a scenario where we do the following in a <b>builder</b>:
1. We have an existing file in an eclipse project.
2. We invoke a dll that generates the file again (on the file system). Hence this is from outside eclipse
3. We Read the file again and do some processing on it
When we do this, we find that eclipse has not yet refreshed the file and we end up reading the old file.
We have tried calling .refreshLocal on the genrated file and/or its folder between steps 2 and 3.
We have also tried deleting the file in step 1 but that too doesn't help.
We know that the issue is because of the eclipse taking 'time' to refresh the file. We know this for sure as if we debug and wait for some time in between steps 2 and 3, the error never occurs !
Is there an API which we can use so that the file is refreshed for sure? Maybe we are not refreshing the right way.
Any help is appreciated.
Thanks
Hemant
|
|
|
Re: Issue with deletion of a file and refresh [message #327350 is a reply to message #327333] |
Tue, 15 April 2008 22:46   |
Eclipse User |
|
|
|
Originally posted by: vcciubot.uwaterloo.ca
I'm just beginning to familiarize myself with this type of issue as well.
From what I understand all changes to the workspace must be wrapped in
runnable passed to the workspace:
IWorkspace workspace = ResourcesPlugin.getWorkspace();
workspace.run(myRunnable, myProject, IWorkspace.AVOID_UPDATE, null);
myProject is a rule which happens to be a resource, that synchronizes
concurrent modifications. The correct rule for the refresh is obtained
as follows:
ResourcesPlugin.getWorkspace().getRuleFactory()
.refreshRule(makefile.getParent())
Here I'm trying to refresh the folder containing my makefile.
This way, the following scenario works for me:
- resource creation from the workbench
- file creation on the disk (outside the workbench)
- refresh vs IResource.refreshLocal
- more modification via the workbench
For more see
http://help.eclipse.org/help33/topic/org.eclipse.platform.do c.isv/guide/resAdv_batching.htm
vlad
On Tue, 15 Apr 2008 12:47:00 -0400, Hemant wrote:
> Hi,
>
> We have a scenario where we do the following in a <b>builder</b>:
>
> 1. We have an existing file in an eclipse project.
> 2. We invoke a dll that generates the file again (on the file system). Hence this is from outside eclipse
> 3. We Read the file again and do some processing on it
>
> When we do this, we find that eclipse has not yet refreshed the file and we end up reading the old file.
> We have tried calling .refreshLocal on the genrated file and/or its folder between steps 2 and 3.
> We have also tried deleting the file in step 1 but that too doesn't help.
>
> We know that the issue is because of the eclipse taking 'time' to refresh the file. We know this for sure as if we debug and wait for some time in between steps 2 and 3, the error never occurs !
>
> Is there an API which we can use so that the file is refreshed for sure? Maybe we are not refreshing the right way.
>
> Any help is appreciated.
>
> Thanks
> Hemant
|
|
|
|
|
|
|
|
Re: Issue with deletion of a file and refresh [message #327442 is a reply to message #327401] |
Sun, 20 April 2008 09:40  |
Eclipse User |
|
|
|
Originally posted by: hkumar.agrawal.gmail.com
Hi,
I have been trying to work around this problem. However, I have been only partially successful. I have even tried to directly play around with the JDK File api, i.e copy the contents of the file generated from outside workspace into another file and then use this new 'IFile' for further processing of the file. I use ICompilationUnit for this processing and I find that even though I add an Import to the file, it does not get persisted always.
The behavior is inconsistent - somtimes it persists and sometimes its not.
Any suggestions ?
Thanks
Hemant
|
|
|
Powered by
FUDForum. Page generated in 0.07143 seconds