mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +02:00
[184322] progress monitor added along with dstore host file caching in dstore file service layer
This commit is contained in:
parent
6ecacafa7a
commit
7cfdd7ebb0
3 changed files with 64 additions and 26 deletions
|
@ -62,6 +62,8 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
|
||||
protected org.eclipse.dstore.core.model.DataElement _uploadLogElement = null;
|
||||
protected Map _fileElementMap;
|
||||
protected Map _dstoreFileMap;
|
||||
|
||||
private int _bufferUploadSize = IUniversalDataStoreConstants.BUFFER_SIZE;
|
||||
private int _bufferDownloadSize = IUniversalDataStoreConstants.BUFFER_SIZE;
|
||||
protected ISystemFileTypes _fileTypeRegistry;
|
||||
|
@ -83,6 +85,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
{
|
||||
super(dataStoreProvider, msgProvider);
|
||||
_fileElementMap = new HashMap();
|
||||
_dstoreFileMap = new HashMap();
|
||||
_fileTypeRegistry = fileTypeRegistry;
|
||||
}
|
||||
|
||||
|
@ -90,6 +93,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
{
|
||||
super.uninitService(monitor);
|
||||
_fileElementMap.clear();
|
||||
_dstoreFileMap.clear();
|
||||
}
|
||||
|
||||
public String getName()
|
||||
|
@ -777,6 +781,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
}
|
||||
String path = file.getAbsolutePath();
|
||||
_fileElementMap.put(path, element);
|
||||
_dstoreFileMap.put(path, file);
|
||||
return file;
|
||||
}
|
||||
protected IHostFile[] convertToHostFiles(DataElement[] elements, String fileFilter)
|
||||
|
@ -1178,6 +1183,17 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
return element;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param path
|
||||
* @return could be null if there isn't one mapped right now
|
||||
*/
|
||||
public IHostFile getHostFile(String path)
|
||||
{
|
||||
return (IHostFile)_dstoreFileMap.get(path);
|
||||
}
|
||||
|
||||
protected IHostFile[] fetch(IProgressMonitor monitor, String remoteParent, String fileFilter, String queryType)
|
||||
{
|
||||
DataStore ds = getDataStore();
|
||||
|
|
|
@ -22,7 +22,9 @@ import org.eclipse.dstore.core.model.DataElement;
|
|||
import org.eclipse.dstore.core.model.DataStore;
|
||||
import org.eclipse.rse.core.SystemBasePlugin;
|
||||
import org.eclipse.rse.dstore.universal.miners.IUniversalDataStoreConstants;
|
||||
import org.eclipse.rse.internal.services.dstore.files.DStoreFileService;
|
||||
import org.eclipse.rse.internal.services.dstore.files.DStoreHostFile;
|
||||
import org.eclipse.rse.services.files.IHostFile;
|
||||
import org.eclipse.rse.subsystems.files.core.servicesubsystem.AbstractRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
|
@ -31,6 +33,13 @@ import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
|
|||
|
||||
public class DStoreFile extends AbstractRemoteFile implements IRemoteFile
|
||||
{
|
||||
|
||||
private DStoreFileService getDStoreFileService()
|
||||
{
|
||||
FileServiceSubSystem ss = (FileServiceSubSystem)_context.getParentRemoteFileSubSystem();
|
||||
return (DStoreFileService)ss.getFileService();
|
||||
}
|
||||
|
||||
public IRemoteFile getParentRemoteFile()
|
||||
{
|
||||
// because this can get called by eclipse from the main thread, and dstore can have problems with main-thread queries,
|
||||
|
@ -47,6 +56,7 @@ public class DStoreFile extends AbstractRemoteFile implements IRemoteFile
|
|||
String pathOnly = getParentPath();
|
||||
if (pathOnly != null)
|
||||
{
|
||||
DStoreFileService fileService = getDStoreFileService();
|
||||
IRemoteFileSubSystem ss = _context.getParentRemoteFileSubSystem();
|
||||
if (ss != null)
|
||||
{
|
||||
|
@ -61,36 +71,45 @@ public class DStoreFile extends AbstractRemoteFile implements IRemoteFile
|
|||
{
|
||||
// parentFile is already null
|
||||
//parentFile = null;
|
||||
DataStore ds = _dstoreHostFile.getDataElement().getDataStore();
|
||||
DataElement element = ds.createObject(null, IUniversalDataStoreConstants.UNIVERSAL_FOLDER_DESCRIPTOR, "");
|
||||
element.setAttribute(DE.A_VALUE, pathOnly);
|
||||
DStoreHostFile hostParent = new DStoreHostFile(element);
|
||||
parentFile = new DStoreFile((FileServiceSubSystem)ss, _context, (IRemoteFile)null, hostParent);
|
||||
|
||||
IHostFile hostParent = fileService.getHostFile(pathOnly);
|
||||
if (hostParent == null)
|
||||
{
|
||||
DataStore ds = _dstoreHostFile.getDataElement().getDataStore();
|
||||
DataElement element = ds.createObject(null, IUniversalDataStoreConstants.UNIVERSAL_FOLDER_DESCRIPTOR, "");
|
||||
element.setAttribute(DE.A_VALUE, pathOnly);
|
||||
|
||||
hostParent = new DStoreHostFile(element);
|
||||
}
|
||||
parentFile = new DStoreFile((FileServiceSubSystem)ss, _context, (IRemoteFile)null, (DStoreHostFile)hostParent);
|
||||
}
|
||||
else if (!(pathOnly.charAt(pathOnly.length()-1)==sep))
|
||||
{
|
||||
DataStore ds = _dstoreHostFile.getDataElement().getDataStore();
|
||||
|
||||
int nameSep = pathOnly.lastIndexOf(sep);
|
||||
String parentName = pathOnly;
|
||||
String parentPath = pathOnly;
|
||||
if (nameSep > 0)
|
||||
|
||||
IHostFile hostParent = fileService.getHostFile(pathOnly);
|
||||
if (hostParent == null)
|
||||
{
|
||||
parentName = pathOnly.substring(nameSep + 1);
|
||||
parentPath = pathOnly.substring(0, nameSep);
|
||||
int nameSep = pathOnly.lastIndexOf(sep);
|
||||
String parentName = pathOnly;
|
||||
String parentPath = pathOnly;
|
||||
if (nameSep > 0)
|
||||
{
|
||||
parentName = pathOnly.substring(nameSep + 1);
|
||||
parentPath = pathOnly.substring(0, nameSep);
|
||||
}
|
||||
else
|
||||
{
|
||||
parentName = pathOnly.substring(nameSep + 1);
|
||||
parentPath = "" + sep;
|
||||
}
|
||||
|
||||
DataElement element = ds.createObject(null, IUniversalDataStoreConstants.UNIVERSAL_FOLDER_DESCRIPTOR, parentName);
|
||||
element.setAttribute(DE.A_VALUE, parentPath);
|
||||
|
||||
hostParent = new DStoreHostFile(element);
|
||||
}
|
||||
else
|
||||
{
|
||||
parentName = pathOnly.substring(nameSep + 1);
|
||||
parentPath = "" + sep;
|
||||
}
|
||||
|
||||
DataElement element = ds.createObject(null, IUniversalDataStoreConstants.UNIVERSAL_FOLDER_DESCRIPTOR, parentName);
|
||||
element.setAttribute(DE.A_VALUE, parentPath);
|
||||
|
||||
|
||||
DStoreHostFile hostParent = new DStoreHostFile(element);
|
||||
parentFile = new DStoreFile((FileServiceSubSystem)ss, _context, (IRemoteFile)null, hostParent);
|
||||
parentFile = new DStoreFile((FileServiceSubSystem)ss, _context, (IRemoteFile)null, (DStoreHostFile)hostParent);
|
||||
//parentFile = ss.getRemoteFileObject(pathOnly+sep);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.eclipse.rse.internal.subsystems.files.dstore;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.dstore.core.model.DataElement;
|
||||
import org.eclipse.dstore.extra.DomainEvent;
|
||||
import org.eclipse.rse.core.subsystems.RemoteChildrenContentsType;
|
||||
|
@ -68,6 +70,7 @@ public class DStoreFileSubSystemSearchResultConfiguration extends DStoreSearchRe
|
|||
List results = getStatusObject().getNestedData();
|
||||
if (results != null)
|
||||
{
|
||||
IProgressMonitor monitor = new NullProgressMonitor();
|
||||
IRemoteFile[] convertedResults = new IRemoteFile[results.size()];
|
||||
for (int i = 0; i < results.size(); i++)
|
||||
{
|
||||
|
@ -77,7 +80,7 @@ public class DStoreFileSubSystemSearchResultConfiguration extends DStoreSearchRe
|
|||
IRemoteFile parentRemoteFile = null;
|
||||
try
|
||||
{
|
||||
parentRemoteFile = _fileSubSystem.getRemoteFileObject(fileNode.getValue());
|
||||
parentRemoteFile = _fileSubSystem.getRemoteFileObject(fileNode.getValue(),monitor);
|
||||
if (!parentRemoteFile.hasContents(RemoteChildrenContentsType.getInstance()))
|
||||
{
|
||||
// query all files to save time (so we can retrieve cached files
|
||||
|
@ -85,7 +88,7 @@ public class DStoreFileSubSystemSearchResultConfiguration extends DStoreSearchRe
|
|||
}
|
||||
|
||||
String path = fileNode.getValue() + "/" + fileNode.getName(); //$NON-NLS-1$
|
||||
IRemoteFile remoteFile = _fileSubSystem.getRemoteFileObject(path);
|
||||
IRemoteFile remoteFile = _fileSubSystem.getRemoteFileObject(path, monitor);
|
||||
|
||||
List contained = fileNode.getNestedData();
|
||||
if (contained != null)
|
||||
|
|
Loading…
Add table
Reference in a new issue