Bug 192724 - [ftp] New Filter with Show Files Only still shows folders
Summary: [ftp] New Filter with Show Files Only still shows folders
Status: CLOSED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 2.0.1   Edit
Assignee: Javier Montalvo Orús CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-14 13:36 EDT by Kevin Doyle CLA
Modified: 2012-05-23 17:29 EDT (History)
3 users (show)

See Also:
mober.at+eclipse: pmc_approved+
dmcknigh: review+


Attachments
Patch (1.78 KB, patch)
2007-06-18 07:11 EDT, Javier Montalvo Orús CLA
no flags Details | Diff
Patch using isRightType(fileType, f) (1.26 KB, patch)
2007-07-19 11:16 EDT, Javier Montalvo Orús CLA
no flags Details | Diff
Patch to filter folders if fileType==FILE_TYPE_FOLDERS (2.89 KB, patch)
2007-07-19 13:24 EDT, Martin Oberhuber CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Doyle CLA 2007-06-14 13:36:25 EDT
Using an ftp connection create a new filter and select show files only.  The new filter will display folders still.

Steps to Reproduce:
1. Create an ftp-only connection.
2. Find a folder with files and folders under it.
3. Right click on the folder and select New -> Filter.
4. Select "Show Files Only" and click Next.
5. Enter some name and Click Finish.
6. Go to the new filter and it will display files and folders.

-----------Enter bugs above this line-----------
TM 2.0RC2 Testing
installation : eclipse-SDK-3.3RC3
RSE install  : RSE 2.0 RC2
java.runtime : Sun 1.5.0_11-b03
os.name:     : Windows XP, Service Pack 2
------------------------------------------------
Comment 1 Javier Montalvo Orús CLA 2007-06-18 07:11:07 EDT
Created attachment 71596 [details]
Patch

Patch showing files only when required by a filter
Comment 2 Javier Montalvo Orús CLA 2007-06-18 07:19:45 EDT
After RC3, all available committers must also review and agree in a vote after reviewing the bug for appropriateness and risk.

TM committers: Can you review and vote it for 2.0RC4 ?
Otherwise, the fix will go to RSE 2.0.1.
Comment 3 Javier Montalvo Orús CLA 2007-06-18 07:21:29 EDT
Marked as fixed by mistake, reopened
Comment 4 Javier Montalvo Orús CLA 2007-06-19 12:09:31 EDT
Marked to be fixed in RSE 2.0.1 as agreed in the committer conference call
Comment 5 Martin Oberhuber CLA 2007-06-28 08:17:30 EDT
Hm... looking at the patch, it appears that if only folders are requested, the name is not checked and ANY folder will be allowed. Is this expected? Or wouldn't we want to restrict folders to those matching the pattern, if only folders are requested?

NOT approving (-1) until this is resolved.
Adding DaveD to CC for comments since he is the Filter expert.
Comment 6 Javier Montalvo Orús CLA 2007-06-29 09:19:44 EDT
 (In reply to comment #5)
> Hm... looking at the patch, it appears that if only folders are requested, the
> name is not checked and ANY folder will be allowed. Is this expected? Or
> wouldn't we want to restrict folders to those matching the pattern, if only
> folders are requested?

The filter only get applied to file names. Folders are shown to allow browsing the subfolders as well.
In fact, I won't expect the "folders only" option to be used from RSE, I have implemented it just to cover all the possible values of file types.
Comment 7 Javier Montalvo Orús CLA 2007-07-17 11:53:39 EDT
Applied the patch allowing top show files only in the filters
Comment 8 Martin Oberhuber CLA 2007-07-18 09:30:39 EDT
Javier I'm not happy that you commit a patch that I have voted "-" on.
This has not been approved -- we should have sorted out my concerns.

Although you are right that FILE_TYPE_FOLDERS might never be used from within the RSE UI, I think it makes sense to implement it properly from an API point of view. The fix is relatively simple:

switch(fileType) {
case FILE_TYPE_FOLDERS:
    if(f.isDirectory() && filematcher.matches(f.getName())) {
	results.add(f);	
    }
    break;

This will ensure that in case only folders are requested, the name matcher is used; if files and folders are requested, or only files are requested, it always returns any folder name.

Reopening to address this concern.
Comment 9 Javier Montalvo Orús CLA 2007-07-18 09:50:25 EDT
(In reply to comment #8)
> Javier I'm not happy that you commit a patch that I have voted "-" on.
> This has not been approved -- we should have sorted out my concerns.
> 
> Although you are right that FILE_TYPE_FOLDERS might never be used from within
> the RSE UI, I think it makes sense to implement it properly from an API point
> of view. The fix is relatively simple:
> 
> switch(fileType) {
> case FILE_TYPE_FOLDERS:
>     if(f.isDirectory() && filematcher.matches(f.getName())) {
>         results.add(f); 
>     }
>     break;
> 
> This will ensure that in case only folders are requested, the name matcher is
> used; if files and folders are requested, or only files are requested, it
> always returns any folder name.

The same behaviour is followed by ssh, so folders are never filtered by name.
If it makes more sense, I can use org.eclipse.rse.services.files.AbstractFileService.isRightType(int, IHostFile) instead of a custom swtich

Comment 10 Javier Montalvo Orús CLA 2007-07-19 11:16:29 EDT
Created attachment 74162 [details]
Patch using isRightType(fileType, f)

Patch replacing the custom switch by isRightType
Comment 11 Martin Oberhuber CLA 2007-07-19 13:24:50 EDT
Created attachment 74169 [details]
Patch to filter folders if fileType==FILE_TYPE_FOLDERS

Javier, you did not get what I meant -- your new patch is nice because it reduces code but still it always returns all the folders. I meant that if only folders are requested, the pattern matcher should be applied to the folders!

Attached patch fixes the issue for both FTP and SSH -- you were right that ssh also did it wrongly.

I also verified with DStore. WHen I'm reading the code right, the relevant place is in UniversalFileSystemMiner line 80:

      if (includeFilesOrFolders != IClientServerConstants.INCLUDE_ALL)
    	  match = matcher.matches(name);

When not both files and folders are requested (but only folders), then the pattern matcher is always applied, so it also filters the folders, and it does NOT return all the folders.

Please read, understand, and commit attached patch.
Comment 12 Martin Oberhuber CLA 2007-07-19 13:26:04 EDT
Dave's -- can you confirm my view of things?
Comment 13 David McKnight CLA 2007-07-19 13:48:44 EDT
The patch looks good to me.
Comment 14 Martin Oberhuber CLA 2007-07-23 10:35:34 EDT
Patch committed, thanks:
[192724] Fixed logic to filter folders if FILE_TYPE_FOLDERS
   FTPService
   SftpFileService
Comment 15 Martin Oberhuber CLA 2007-07-23 11:02:49 EDT
Released for I20070723
Comment 16 Kevin Doyle CLA 2007-07-24 09:26:41 EDT
Verified with I20070724-0735.
Comment 17 Martin Oberhuber CLA 2012-05-23 17:29:36 EDT
Comment on attachment 71596 [details]
Patch

Javier's Patch was not used.