Bug 191048 - [ftp] Remote files locally listed and being removed by other users should be reported as missing
Summary: [ftp] Remote files locally listed and being removed by other users should be ...
Status: RESOLVED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: 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-05 10:57 EDT by Javier Montalvo Orús CLA
Modified: 2012-05-23 17:13 EDT (History)
1 user (show)

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


Attachments
Patch showing an "File not found" error message (3.42 KB, patch)
2007-07-17 15:10 EDT, Javier Montalvo Orús CLA
no flags Details | Diff
Patch showing the remote error message (4.68 KB, patch)
2007-07-30 07:05 EDT, Javier Montalvo Orús CLA
no flags Details | Diff
Patch showing the remote error message and throwing RemoteFileCancelledException if cancelled (4.62 KB, patch)
2007-07-30 11:48 EDT, Javier Montalvo Orús CLA
mober.at+eclipse: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Javier Montalvo Orús CLA 2007-06-05 10:57:45 EDT
Deleting a file that is shown in the RSE FTP filesystem by external ways (through filesystem or other FTP connection) is not reported as missing by RSE.
The correct behaviour should be reporting that the file is missing.
Comment 1 Javier Montalvo Orús CLA 2007-06-05 10:59:13 EDT
I'd leave it for RSE 2.0.1 since it's not preventing FTP from working, and it seems quite easy to fix
Comment 2 Javier Montalvo Orús CLA 2007-07-17 15:10:22 EDT
Created attachment 73989 [details]
Patch showing an "File not found" error message 

If the remote file has been removed, the RSE FTP client should show a "File not found" message
Comment 3 Martin Oberhuber CLA 2007-07-18 09:06:27 EDT
Dave - this patch contains an NLS change, can we do this for 2.0.1?
Should we search for an existing "file not found" kind message to re-use?
Do you have any other suggestions?
Comment 4 Javier Montalvo Orús CLA 2007-07-25 13:46:10 EDT
Now a translatable error message is displayed if the remote file has been removed and it's attempted to be open/downloaded from RSE.
Comment 5 David Dykstal CLA 2007-07-27 09:55:55 EDT
For 2.0.1 I would prefer that we try to find an existing message rather than adding a new one. We can certainly add new externalized strings in 3.0.
Comment 6 Javier Montalvo Orús CLA 2007-07-27 10:03:26 EDT
I'll try to find an alternative message.
Comment 7 Javier Montalvo Orús CLA 2007-07-27 10:50:16 EDT
I haven't found any suitable string, can you think of any string that would make sense and accessible from org.eclipse.rse.services.files.ftp ?

As an alternative, the raised RemoteFileIOException can be shown with an empty string as a reported message. The exception, when catched, pops up as an error message with:
"Operation failed. File system input or output error", which makes sense, but the error details are empty.
Comment 8 Martin Oberhuber CLA 2007-07-27 11:35:39 EDT
Doesn't the FTP server give use a useful message like

400 FILE NOT FOUND
Comment 9 Martin Oberhuber CLA 2007-07-27 11:35:56 EDT
Reopening until Dave's concern is addressed
Comment 10 Javier Montalvo Orús CLA 2007-07-27 12:36:02 EDT
(In reply to comment #8)
> Doesn't the FTP server give use a useful message like
> 
> 400 FILE NOT FOUND
> 
What the code was doing was preventing accessing a non-existing file, I can instead wait until the retrieve fails and use the FTP failure message in the 'details' of the error popup.
Comment 11 Martin Oberhuber CLA 2007-07-27 12:48:49 EDT
That sounds better because how could you know the file is missing unless you actually tried accessing it? - User could have copied it to the location in the short time between you listing the directory and RSE trying to access it.
Comment 12 Javier Montalvo Orús CLA 2007-07-27 12:57:00 EDT
The LIST command is performed by getFile() to obtaing the IHostFile just before downloading (see comment #6 of bug 195830 for more info)
Eventually, I should remove this call and obtain the file size from somewhere else.
Comment 13 Martin Oberhuber CLA 2007-07-27 13:08:08 EDT
Well I'm not sure where you could get the file size from...

Actually the LIST for getting the file size is OK, but I don't think you need to throw the exception yourself (or even check for null, see below). Just ignore the fact that !remoteFile.exists(). Move the 
    input = ftpClient.retrieveFileStream(remoteFile);
further up in the try{... block. And it should throw a proper exception for you, including the original remote message
    550 aatest: No such file or directory.

When reviewing this, I noticed that your getFile() code is wrong since it must not ever return null. See docs and implementation of SftpFileService#getFile().
Comment 14 Javier Montalvo Orús CLA 2007-07-30 07:05:43 EDT
Created attachment 74918 [details]
Patch showing the remote error message

The attached patch shows the FTP server error message when the remote input stream cannot be open and returns null.
I have also fixed getFile() and it doesn't return null anymore.
Comment 15 Martin Oberhuber CLA 2007-07-30 11:05:10 EDT
Patch looks good for the updated "File not found" message.

But your getFile() implementation is still not correct.
I think it should throw new RemoteFileCancelledException(); in case 
the user canceled.

Otherwise, user would cancel the request and the RSE cache would think the remote file is not there and mark it as not being there - but in reality it does not know.
Comment 16 Javier Montalvo Orús CLA 2007-07-30 11:48:34 EDT
Created attachment 74940 [details]
Patch showing the remote error message and throwing RemoteFileCancelledException if cancelled

Improved patch with Martin suggestion, so now it throws a RemoteFileCancelledException instead of just returning false when the user cancels the action.
Comment 17 Martin Oberhuber CLA 2007-07-30 11:53:44 EDT
Javier you added the throw new RemoteFileCanceledException() in line 679 but it should (also) have been added in line 397.

Please be careful and read the API Docs of IFileService that your service must implement properly. Those methods which return a boolean already on success (e.g. download) may throw RemoteFileCanceledException, but don't have to do so necessarily - it's up to them.

Those methods that return an IHostFile or other specialized object (like getFile()) need to throw the exception in case they are canceled.

It wasn't correct in SftpFileService for 2.0 either, but I fixed it last week so you can reference it now where the exception needs to be thrown.
Comment 18 Javier Montalvo Orús CLA 2007-07-30 11:58:21 EDT
(In reply to comment #17)
> Javier you added the throw new RemoteFileCanceledException() in line 679 but it
> should (also) have been added in line 397.
> 
> Please be careful and read the API Docs of IFileService that your service must
> implement properly. Those methods which return a boolean already on success
> (e.g. download) may throw RemoteFileCanceledException, but don't have to do so
> necessarily - it's up to them.
> 
> Those methods that return an IHostFile or other specialized object (like
> getFile()) need to throw the exception in case they are canceled.
> 
> It wasn't correct in SftpFileService for 2.0 either, but I fixed it last week
> so you can reference it now where the exception needs to be thrown.
> 
I fixed the other places where null was returned in a similar way. 
I haven't added all the modifications in this path as it could be misleading for this bug.
Comment 19 Martin Oberhuber CLA 2007-07-30 12:00:55 EDT
Good, then go for it... for this bug, the patch is good now.
Comment 20 Martin Oberhuber CLA 2007-09-18 07:16:49 EDT
Dave what do you think - I think this patch should be applied now?
Comment 21 Martin Oberhuber CLA 2007-09-26 21:14:56 EDT
I just noticed that this did not make it into 2.0.1 although it was
  - assigned (javier)
  - had a valid and review-approved patch
just because nobody committed the fix.

Do we consider this fix critical?
Javier can you merge the patch so it can be applied to HEAD?
Comment 22 Javier Montalvo Orús CLA 2007-09-27 05:46:06 EDT
I just checked and the patch was applied a while ago, so it's part of 2.0.1
I didn't move the bug status to fixed as I was waiting for dave's review.

Comment 23 Martin Oberhuber CLA 2012-05-23 17:13:16 EDT
Comment on attachment 74940 [details]
Patch showing the remote error message and throwing RemoteFileCancelledException if cancelled

iplog- since Javier was committer since Aug 2006 already:
http://dev.eclipse.org/mhonarc/lists/dsdp-tm-dev/msg00375.html