From 411e15f6dc85cc23ee42b937432e292166791811 Mon Sep 17 00:00:00 2001 From: Dave McKnight Date: Tue, 25 Mar 2014 11:12:23 -0400 Subject: [PATCH] [431060][local] RSE performance over local network drives are suboptimal --- .../local/files/LocalFileService.java | 2 +- .../services/local/files/LocalHostFile.java | 22 ++++++++++++++++++- .../files/local/model/LocalFile.java | 9 +++++--- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java index b3ede99b189..c1a87e0923f 100644 --- a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java +++ b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java @@ -55,7 +55,7 @@ * Samuel Wu (IBM) - [395981] Local file encoding is not handled properly * David McKnight (IBM) - [422508] Unable to map A:\ and B:\ as selectable drives in RSE View * David McKnight (IBM) - [420798] Slow performances in RDz 9.0 with opening 7000 files located on a network driver. - * David McKnight (IBM) - [427306] A couple cases where RSE doesn't indicate lack of space for upload + * David McKnight (IBM) - [431060][local] RSE performance over local network drives are suboptimal *******************************************************************************/ package org.eclipse.rse.internal.services.local.files; diff --git a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalHostFile.java b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalHostFile.java index b7b82a04c9e..c7b9894e641 100644 --- a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalHostFile.java +++ b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalHostFile.java @@ -47,6 +47,7 @@ public class LocalHostFile implements IHostFile, IHostFilePermissionsContainer private boolean _isArchive = false; private IHostFilePermissions _permissions = null; private FileInfo _info = null; + private boolean _needsQuery = false; public LocalHostFile(File file) { @@ -75,6 +76,7 @@ public class LocalHostFile implements IHostFile, IHostFilePermissionsContainer _info.setName(new String(name.toCharArray())); } } + _needsQuery = false; } @@ -162,8 +164,10 @@ public class LocalHostFile implements IHostFile, IHostFilePermissionsContainer public boolean exists() { - if (_exists == null || needsQuery()){ + boolean needsQuery = needsQuery(); + if (_exists == null || needsQuery){ if (_info != null){ + if (needsQuery) fetchInfo(); _exists = new Boolean(_info.exists()); } else { @@ -181,6 +185,7 @@ public class LocalHostFile implements IHostFile, IHostFilePermissionsContainer public long getSize() { if (_info != null){ + if (needsQuery()) fetchInfo(); return _info.getLength(); } return _file.length(); @@ -189,6 +194,7 @@ public class LocalHostFile implements IHostFile, IHostFilePermissionsContainer public long getModifiedDate() { if (_info != null){ + if (needsQuery()) fetchInfo(); return _info.getLastModified(); } return _file.lastModified(); @@ -198,6 +204,7 @@ public class LocalHostFile implements IHostFile, IHostFilePermissionsContainer { _file = new File(newAbsolutePath); _isArchive = ArchiveHandlerManager.getInstance().isArchive(_file); + fetchInfo(); } public boolean isArchive() @@ -207,6 +214,7 @@ public class LocalHostFile implements IHostFile, IHostFilePermissionsContainer public boolean canRead() { if (_info != null){ + if (needsQuery()) fetchInfo(); return _info.getAttribute(EFS.ATTRIBUTE_OWNER_READ); } return _file.canRead(); @@ -214,6 +222,11 @@ public class LocalHostFile implements IHostFile, IHostFilePermissionsContainer public boolean canWrite() { if (_info != null){ + if (needsQuery()) fetchInfo(); + boolean readOnly = _info.getAttribute(EFS.ATTRIBUTE_READ_ONLY); + if (readOnly){ + return false; + } return _info.getAttribute(EFS.ATTRIBUTE_OWNER_WRITE); } return _file.canWrite(); @@ -228,6 +241,9 @@ public class LocalHostFile implements IHostFile, IHostFilePermissionsContainer } private boolean needsQuery(){ + if (LocalFileNativesManager.isUsingNatives() && _needsQuery){ + return true; + } long t = System.currentTimeMillis(); if (_lastQueryTime == 0 || (t - _lastQueryTime) > 5000){ _lastQueryTime = t; @@ -235,4 +251,8 @@ public class LocalHostFile implements IHostFile, IHostFilePermissionsContainer } return false; } + + public void setNeedsQuery(boolean flag){ + _needsQuery = true; + } } diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.local/src/org/eclipse/rse/internal/subsystems/files/local/model/LocalFile.java b/rse/plugins/org.eclipse.rse.subsystems.files.local/src/org/eclipse/rse/internal/subsystems/files/local/model/LocalFile.java index b7af7c270b7..e051f127523 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.local/src/org/eclipse/rse/internal/subsystems/files/local/model/LocalFile.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.local/src/org/eclipse/rse/internal/subsystems/files/local/model/LocalFile.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. + * Copyright (c) 2006, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,6 +14,7 @@ * Contributors: * Martin Oberhuber (Wind River) - [187571] Classification is empty for local directories * Martin Oberhuber (Wind River) - [234726] Update IRemoteFile Javadocs + * David McKnight (IBM) - [431060][local] RSE performance over local network drives are suboptimal *******************************************************************************/ package org.eclipse.rse.internal.subsystems.files.local.model; @@ -74,7 +75,9 @@ public class LocalFile extends AbstractRemoteFile return _classification; } - - + public void markStale(boolean isStale) { + super.markStale(isStale); + _localHostFile.setNeedsQuery(isStale); + } }