Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Issue with deletion of a file and refresh
Issue with deletion of a file and refresh [message #327333] Tue, 15 April 2008 16:47 Go to next message
Eclipse UserFriend
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] Wed, 16 April 2008 02:46 Go to previous messageGo to next message
Eclipse UserFriend
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 #327360 is a reply to message #327350] Wed, 16 April 2008 13:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hkumar.agrawal.gmail.com

Hi,

Thanks for the reply. However that does not solve the problem. I tried several rules for the WorkspaceRunnable. Also I put the operations of deletion of the file, generation of the file and modification of the file into WorkspaceRunnables. Still no luck !

I am using eclipse 3.3.1.1.
Is there an API that can guarantee the refresh of a file OR is there a way in which I can achieve that ?

While playing with the APIs, I found that after generation of the file, the api <i>file</i>.isSynchronized() is able to detect that the file is not in sync. At this point if I call refreshLocal on the file, the file is thought to be in sync as another call to isSynchronized returns true but actually the file is not refreshed.

Any help is well appreciated.

Thanks
Hemant
Re: Issue with deletion of a file and refresh [message #327361 is a reply to message #327360] Wed, 16 April 2008 14:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vcciubot.uwaterloo.ca

In the runnable that creates the file from outside the workbench, did you
include the refresh of the parent folder using IResource.refreshLocal()
immediately after the creation/modification from outside? That's what I do
and it works fine.

Let me know.

vlad

On Wed, 16 Apr 2008 09:44:08 -0400, Hemant wrote:

> Hi,
>
> Thanks for the reply. However that does not solve the problem. I tried several rules for the WorkspaceRunnable. Also I put the operations of deletion of the file, generation of the file and modification of the file into WorkspaceRunnables. Still no luck !
>
> I am using eclipse 3.3.1.1.
> Is there an API that can guarantee the refresh of a file OR is there a way in which I can achieve that ?
>
> While playing with the APIs, I found that after generation of the file, the api <i>file</i>.isSynchronized() is able to detect that the file is not in sync. At this point if I call refreshLocal on the file, the file is thought to be in sync as another call to isSynchronized returns true but actually the file is not refreshed.
>
> Any help is well appreciated.
>
> Thanks
> Hemant
Re: Issue with deletion of a file and refresh [message #327365 is a reply to message #327361] Wed, 16 April 2008 16:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hkumar.agrawal.gmail.com

Yes, I tried that too. Having done that, file.isSynchronized() thinks that the file is synchronized, when its still not !
Its still reading from the old file.
Re: Issue with deletion of a file and refresh [message #327372 is a reply to message #327365] Wed, 16 April 2008 17:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vcciubot.uwaterloo.ca

Is the filesystem network mounted? If so see a few thread below.

On Wed, 16 Apr 2008 12:01:10 -0400, Hemant wrote:

> Yes, I tried that too. Having done that, file.isSynchronized() thinks that the file is synchronized, when its still not !
> Its still reading from the old file.
Re: Issue with deletion of a file and refresh [message #327401 is a reply to message #327372] Thu, 17 April 2008 16:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hkumar.agrawal.gmail.com

The file system is not network mounted. Its local. I have tried this on a file systems with NTFS and FAT32 partitions. Also tried it on an XP and Win 2k machine.
It seems to me as a bug in the platform code.

Further, the refresh issue is there even while writing ! I tried the following:
1. Read the file generated from outside eclipse directly using the java.util.File
2. Created a new IFile based on the 'contents' of file read in 1
3. Create 2 compilation units - first from the new file created in 2 and second from the 'original' file
4. Modified the actual compilation unit (i.e. the second one)
5. I print the compilation using usint the toString and it shows me the change I made. However when I save the compilation unit, the change is not persisted to the disk.

Regards
Hemant
Re: Issue with deletion of a file and refresh [message #327442 is a reply to message #327401] Sun, 20 April 2008 13:40 Go to previous message
Eclipse UserFriend
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
Previous Topic:Plugin doesn't get loaded after deployment
Next Topic:Embedding Swing toolbar using SWT_AWT Bridge?
Goto Forum:
  


Current Time: Wed Jul 17 20:29:55 GMT 2024

Powered by FUDForum. Page generated in 0.04477 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top