### Eclipse Workspace Patch 1.0 #P org.eclipse.rse.subsystems.files.core Index: src/org/eclipse/rse/subsystems/files/core/subsystems/IRemoteFile.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/IRemoteFile.java,v retrieving revision 1.14 diff -u -r1.14 IRemoteFile.java --- src/org/eclipse/rse/subsystems/files/core/subsystems/IRemoteFile.java 21 May 2008 20:36:50 -0000 1.14 +++ src/org/eclipse/rse/subsystems/files/core/subsystems/IRemoteFile.java 3 Jun 2008 16:00:14 -0000 @@ -53,6 +53,8 @@ *

* Note for subsystem providers: this method does not capture the set methods that the * RemoteFileImpl class defines. For that, cast to IRemoteFileMutable. + * + * @noimplement This interface is not intended to be implemented by clients. Clients should extend AbstractRemoteFile instead. */ public interface IRemoteFile extends IRemoteContainer, IRemotePropertyHolder, ISchedulingRule { Index: src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFile.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFile.java,v retrieving revision 1.37 diff -u -r1.37 RemoteFile.java --- src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFile.java 22 May 2008 13:24:03 -0000 1.37 +++ src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFile.java 3 Jun 2008 16:00:15 -0000 @@ -77,6 +77,7 @@ * that information is properly set by some means such that the {@link IRemoteFile#exists()}, * {@link IRemoteFile#getAbsolutePath()}, {@link IRemoteFile#getLength()} * and similar methods can be implemented. + * */ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable { Index: src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java,v retrieving revision 1.71 diff -u -r1.71 FileServiceSubSystem.java --- src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java 26 May 2008 23:21:45 -0000 1.71 +++ src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java 3 Jun 2008 16:00:14 -0000 @@ -443,7 +443,12 @@ } if (underParent.size() > 0) { - parent.setContents(RemoteChildrenContentsType.getInstance(), filter, underParent.toArray()); + IRemoteFile[] qresults = (IRemoteFile[])underParent.toArray(new IRemoteFile[underParent.size()]); + + // update the remote file + updateRemoteFile(parent, qresults, monitor); + + parent.setContents(RemoteChildrenContentsType.getInstance(), filter, qresults); } } @@ -467,6 +472,7 @@ parentPaths[i] = parents[i].getAbsolutePath(); } + List hostFiles = new ArrayList(10); getFileService().listMultiple(parentPaths, fileNameFilters, fileType, hostFiles, monitor); IHostFile[] results = new IHostFile[hostFiles.size()]; @@ -496,7 +502,12 @@ } if (underParent.size() > 0) { - parent.setContents(RemoteChildrenContentsType.getInstance(), filter, underParent.toArray()); + IRemoteFile[] qresults = (IRemoteFile[])underParent.toArray(new IRemoteFile[underParent.size()]); + + // update the remote file + updateRemoteFile(parent, qresults, monitor); + + parent.setContents(RemoteChildrenContentsType.getInstance(), filter, qresults); } } @@ -533,16 +544,110 @@ IStatus.INFO, msgTxt); throw new SystemMessageException(msg); } - + IHostFile[] results = internalList(parentPath, fileNameFilter, fileType, monitor); - + updateRemoteFile(parent, results, monitor); + IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, parent, results); if (parent != null) parent.setContents(RemoteChildrenContentsType.getInstance(), fileNameFilter, farr); return farr; } - + private void updateRemoteFile(IRemoteFile parent, IRemoteFile[] results, IProgressMonitor monitor) + { + IHostFile newHostParent = null; + String parentPath = parent.getAbsolutePath(); + + // look for the "." file to determine whether we have an updated parent in the results + for (int i = 0; i < results.length && newHostParent == null; i++){ + IRemoteFile result = results[i]; + + if (!result.getParentPath().equals(parentPath)){ + newHostParent = result.getHostFile(); // we think the child is the same as the parent + } + } + + // didn't find "." file, so we'll assume it wasn't returned and explicitly get it + if (newHostParent == null){ + String parentParentPath = parent.getParentPath(); + if (parentParentPath == null){ + parentParentPath = ""; //$NON-NLS-1$ + } + try { + newHostParent = getFileService().getFile(parentParentPath, parent.getName(), monitor); + } + catch (SystemMessageException e){ + + } + } + else { // remove the updated parent from the results + IRemoteFile[] oldResults = results; + results = new IRemoteFile[oldResults.length - 1]; + int n = 0; + for (int o = 0; o < oldResults.length; o++){ + IRemoteFile oldResult = oldResults[o]; + if (oldResult.getHostFile() != newHostParent){ + results[n] = oldResult; + n++; + } + } + } + + if (newHostParent != null){ + IHostFile oldHostParent = parent.getHostFile(); + if (!newHostParent.equals(oldHostParent)){ + ((AbstractRemoteFile)parent).setHostFile(newHostParent); + parent.markStale(false); + } + } + } + private void updateRemoteFile(IRemoteFile parent, IHostFile[] results, IProgressMonitor monitor) + { + IHostFile newHostParent = null; + String parentPath = parent.getAbsolutePath(); + + // look for the "." file to determine whether we have an updated parent in the results + for (int i = 0; i < results.length && newHostParent == null; i++){ + IHostFile result = results[i]; + if (!result.getParentPath().equals(parentPath)){ + newHostParent = result; // we think the child is the same as the parent + } + } + + // didn't find "." file, so we'll assume it wasn't returned and explicitly get it + if (newHostParent == null){ + String parentParentPath = parent.getParentPath(); + if (parentParentPath == null){ + parentParentPath = ""; //$NON-NLS-1$ + } + try { + newHostParent = getFileService().getFile(parentParentPath, parent.getName(), monitor); + } + catch (SystemMessageException e){ + } + } + else { // remove the updated parent from the results + IHostFile[] oldResults = results; + results = new IHostFile[oldResults.length - 1]; + int n = 0; + for (int o = 0; o < oldResults.length; o++){ + IHostFile oldResult = oldResults[o]; + if (oldResult != newHostParent){ + results[n] = oldResult; + n++; + } + } + } + + if (newHostParent != null){ + IHostFile oldHostParent = parent.getHostFile(); + if (!newHostParent.equals(oldHostParent)){ + ((AbstractRemoteFile)parent).setHostFile(newHostParent); + parent.markStale(false); + } + } + } public IRemoteFile[] listRoots(IRemoteFileContext context, IProgressMonitor monitor) throws InterruptedException { Index: src/org/eclipse/rse/subsystems/files/core/servicesubsystem/AbstractRemoteFile.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/AbstractRemoteFile.java,v retrieving revision 1.9 diff -u -r1.9 AbstractRemoteFile.java --- src/org/eclipse/rse/subsystems/files/core/servicesubsystem/AbstractRemoteFile.java 21 May 2008 20:36:50 -0000 1.9 +++ src/org/eclipse/rse/subsystems/files/core/servicesubsystem/AbstractRemoteFile.java 3 Jun 2008 16:00:14 -0000 @@ -199,5 +199,9 @@ return _hostFile; } + public void setHostFile(IHostFile file) + { + _hostFile = file; + } }