| Summary: | IRemoteFile.exists() method does not reflect exact state, once the existence of the remote file changed after the creation of the instance. | ||
|---|---|---|---|
| Product: | [Tools] Target Management | Reporter: | Loganathan <loganathan001> |
| Component: | RSE | Assignee: | dsdp.tm.rse-inbox <tm.rse-inbox> |
| Status: | NEW --- | QA Contact: | Martin Oberhuber <mober.at+eclipse> |
| Severity: | major | ||
| Priority: | P3 | CC: | dmcknigh |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
|
Description
Loganathan
To avoid performance problems due to redundant remote queries, the IRemoteFile instances are cached. If you create an IRemoteFile handle, then manually create the file, you'll need to first do the following before you'll have an up-to-date version with an accurate IRemoteFile.exists(): // make the cached file stale remoteFile.markStale(true); // requery it to obtain a fresh version remoteFile =fs.getRemoteFileObject(remoteFile.getAbsolutePath(), monitor); (In reply to comment #1) > To avoid performance problems due to redundant remote queries, the IRemoteFile > instances are cached. If you create an IRemoteFile handle, then manually > create the file, you'll need to first do the following before you'll have an > up-to-date version with an accurate IRemoteFile.exists(): > > // make the cached file stale > remoteFile.markStale(true); > > // requery it to obtain a fresh version > remoteFile =fs.getRemoteFileObject(remoteFile.getAbsolutePath(), monitor); Thanks.. As per my case, I create many the remote file/folder handles, which I'm supposed to create manually(actually running a script) which may or many not be created. So the method IRemoteFile.exists() becomes not affordable and un-usable because I don't know which which remote files/folders are actually created, and I need to create and use my own 'exists' method in MyRemoteUtil.. public static boolean IsRemoteFileExists(IRemoteFile remoteFile) { // make the cached file stale remoteFile.markStale(true); // requery it to obtain a fresh version remoteFile =fs.getRemoteFileObject(remoteFile.getAbsolutePath(), monitor); return remoteFile.exists(); } and should not use the IRemoteFile.exists(). My suggestion is either to make IRemoteFile.exists() as transparent or provide an additional method to provide the transparent result. But I know that this is up to you developer/maintainer's decision.. Thanks.. I'm not sure whether this will help in your multiple handles scenario, but I'll pass this on just in case. The file subsystem has the following method that can be used to query multiple files in one call: /** * Given a set of fully qualified file or folder names, return an ISystemResourceSet object for it. * @param folderOrFileNames Fully qualified folder or file names * @param monitor the progress monitor * * @return the set of resources * @since 3.0 */ public IRemoteFile[] getRemoteFileObjects(String[] folderOrFileNames, IProgressMonitor monitor) throws SystemMessageException; Of course, if files don't exist at the time of the query, then none of the handles will return true for IRemoteFile.exists(). Is there any reason why you can't run the script first and then query the files? (In reply to comment #3) > I'm not sure whether this will help in your multiple handles scenario, but I'll > pass this on just in case. The file subsystem has the following method that > can be used to query multiple files in one call: > > /** > * Given a set of fully qualified file or folder names, return an > ISystemResourceSet object for it. > * @param folderOrFileNames Fully qualified folder or file names > * @param monitor the progress monitor > * > * @return the set of resources > * @since 3.0 > */ > public IRemoteFile[] getRemoteFileObjects(String[] folderOrFileNames, > IProgressMonitor monitor) throws SystemMessageException; > > Of course, if files don't exist at the time of the query, then none of the > handles will return true for IRemoteFile.exists(). Is there any reason why you > can't run the script first and then query the files? Hi, thanks.. Of course, I can find a way to re-write my code flow to query the files after running the script. But there should be the proper documentation for the IRemoteFile.exists() method saying that it is not usable for files that don't exist, or should not allow to create the handle or return null or exception while creating the handle for a non-existing resource.. without which it took half a day for me to find the cause. Thanks.. (In reply to comment #4) > (In reply to comment #3) > > I'm not sure whether this will help in your multiple handles scenario, but I'll > > pass this on just in case. The file subsystem has the following method that > > can be used to query multiple files in one call: > > > > /** > > * Given a set of fully qualified file or folder names, return an > > ISystemResourceSet object for it. > > * @param folderOrFileNames Fully qualified folder or file names > > * @param monitor the progress monitor > > * > > * @return the set of resources > > * @since 3.0 > > */ > > public IRemoteFile[] getRemoteFileObjects(String[] folderOrFileNames, > > IProgressMonitor monitor) throws SystemMessageException; > > > > Of course, if files don't exist at the time of the query, then none of the > > handles will return true for IRemoteFile.exists(). Is there any reason why you > > can't run the script first and then query the files? > > Hi, thanks.. > > Of course, I can find a way to re-write my code flow to query the files after > running the script. But there should be the proper documentation for the > IRemoteFile.exists() method saying that it is not usable for files that don't > exist, or should not allow to create the handle or return null or exception > while creating the handle for a non-existing resource.. without which it took > half a day for me to find the cause. > > Thanks.. Fair enough, further documentation should be added to mention that IRemoteFile handles are created whether the files exist or not and that, in order to get an updated version of a file's state, the remote file needs to first be marked stale and then requeried. |