This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 276535 - File Conflict when Importing Remote Folder with Case-Differentiated-Only Filenames into Project
Summary: File Conflict when Importing Remote Folder with Case-Differentiated-Only File...
Status: RESOLVED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 RC3   Edit
Assignee: David McKnight CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords:
Depends on: 276103
Blocks:
  Show dependency tree
 
Reported: 2009-05-15 12:59 EDT by Simon Elliott CLA
Modified: 2009-06-04 15:25 EDT (History)
1 user (show)

See Also:
mober.at+eclipse: pmc_approved+


Attachments
patch with case check and display of message (3.94 KB, patch)
2009-05-15 15:05 EDT, David McKnight CLA
no flags Details | Diff
patch that checks for existance without using internal.resources (3.05 KB, patch)
2009-05-28 10:33 EDT, David McKnight CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Elliott CLA 2009-05-15 12:59:49 EDT
Version: 3.5.0
Build id: I20090512-2000

After importing a remote directory in which files exist differentiated only by case into a project, all instances of said files will be overwritten with the last such file in the directory listing. Remote copies are unaffected.

1. Create a new local project in Java perspective.
2. Switch to RSE perspective. In a folder in a unix-based remote system, create 'test.txt' and 'TEST.txt'
3. Right click the folder, and select 'Import into Project'
4. View the project in the Package Explorer in the Java perspective. Note that only TEST.txt has been imported.

This effect is also reproducible with case-differentiated-only folders. Folder contents will be merged and overwritten.
Comment 1 David McKnight CLA 2009-05-15 15:05:40 EDT
Created attachment 136053 [details]
patch with case check and display of message

Could you try with this patch?
Comment 2 Simon Elliott CLA 2009-05-19 09:08:29 EDT
Patch generates warning, only imports first-listed file. Suitably addresses issue, but does not resolve it; however, it should be sufficient to motivate users to resolve conflict manually.
Comment 3 David McKnight CLA 2009-05-19 11:16:14 EDT
(In reply to comment #2)
> Patch generates warning, only imports first-listed file. Suitably addresses
> issue, but does not resolve it; however, it should be sufficient to motivate
> users to resolve conflict manually.
> 

From my tests, it looks like all listed files are attempted on the import.  Are you saying that only the first-listed file is imported or just that the first failed import is shown?
Comment 4 Simon Elliott CLA 2009-05-19 11:27:27 EDT
I was noting that only the first-listed file is imported, whereas previously the action overwrote without prompting, effectively importing only the last-listed file. Failure notices are generated as expected, and in my tests, all files were attempted. From what I see, failure notices do not conflict with uniquely-named files listed after the case-differentiated-only ones. The patch does what it should.
Comment 5 David McKnight CLA 2009-05-19 11:34:28 EDT
(In reply to comment #4)
> I was noting that only the first-listed file is imported, whereas previously
> the action overwrote without prompting, effectively importing only the
> last-listed file. Failure notices are generated as expected, and in my tests,
> all files were attempted. From what I see, failure notices do not conflict with
> uniquely-named files listed after the case-differentiated-only ones. The patch
> does what it should.
> 

Okay.  Improvements could also be made to display multiple conflicts - since right now only the first conflict is displayed.  Since RSE 3.1 has past it's UI-freeze, that part will have to wait.  I'll commit the current patch to cvs.
Comment 6 David McKnight CLA 2009-05-19 11:35:36 EDT
I've committed the fix.
Comment 7 Martin Oberhuber CLA 2009-05-27 16:39:39 EDT
Since we are in RC endgame, this fix will need another commiter's +1 before it can be released. See bug 276103 for a discussion.
Comment 8 Martin Oberhuber CLA 2009-05-27 16:48:55 EDT
I cannot approve the use of org.eclipse.core.internal.resources non-API in RemoteFileImportOperation. We are bound to using public API only per Galileo Requirement, and clean up our technical debt rather than introducing new one.

Isn't there an official way for finding out whether a file exists?
Comment 9 David McKnight CLA 2009-05-28 10:33:02 EDT
Created attachment 137492 [details]
patch that checks for existance without using internal.resources

How about this approach instead?  I am referencing an internal message from our own files.core plugin but at least it's our own.
Comment 10 David McKnight CLA 2009-06-03 12:40:23 EDT
I've committed the updated patch to cvs.
Comment 11 Martin Oberhuber CLA 2009-06-03 14:15:05 EDT
New patch looks better, but what if a FOLDER with same name but different case already exists? For instance:

Foo/
  Bar/
    test.txt
  bar

Shouldn't this be reported as an error es well on import? Also, what happens when exporting from case-sensitive file system to a case-insensitive one?

I'm not necessarily in favor of changing all code for this now, but we should be aware of potential problems and decide what's the right thing to do.

In case of the issue mentioned above, I think the 
   existingFileInDifferentCase(IFile)
method should likely better return an IResource (which can also be an IFolder) in case a name clash is detected.

Please be sure to test the scenario.
Comment 12 David McKnight CLA 2009-06-03 14:45:50 EDT
(In reply to comment #11)
> New patch looks better, but what if a FOLDER with same name but different case
> already exists? For instance:
> 
> Foo/
>   Bar/
>     test.txt
>   bar
> 
> Shouldn't this be reported as an error es well on import? Also, what happens
> when exporting from case-sensitive file system to a case-insensitive one?
> 
> I'm not necessarily in favor of changing all code for this now, but we should
> be aware of potential problems and decide what's the right thing to do.
> 
> In case of the issue mentioned above, I think the 
>    existingFileInDifferentCase(IFile)
> method should likely better return an IResource (which can also be an IFolder)
> in case a name clash is detected.
> 
> Please be sure to test the scenario.
> 


I created the following structure:

FLD/abc.c
fld/test.txt

When I try to import it, I get the following message:

Unexpected exception received: Unable to import /home/dmcknigh/111/fld/test.txt: A resource exists with a different case: '/local/FLD'..


To compare with Eclipse, I created a local archive with the following structure:

FLD1/test.txt
fld1/test2.txt

When I try to import it via the Archive file import wizard, I get the following message:

Problems were encountered during import:
  Unable to import fld1/test2.txt.  Reason: A resource exists with a different case: '/local/FLD1'.

So the behaviour is more or less the same.


Comment 13 Martin Oberhuber CLA 2009-06-03 17:26:37 EDT
(In reply to comment #12)
Interesting. Looking at the code, I cannot see how it would detect fld versus FLD on remote imort, can you?

Did you also try folder ("fld") versus file ("FLD") ?
Comment 14 Martin Oberhuber CLA 2009-06-03 22:27:10 EDT
I'm releasing the fix into RC3 although I'd still like to understand why folder import with different case is properly reported.
Comment 15 David McKnight CLA 2009-06-04 15:22:17 EDT
(In reply to comment #13)
> (In reply to comment #12)
> Interesting. Looking at the code, I cannot see how it would detect fld versus
> FLD on remote imort, can you?
> 

Here's the exception we get in this case:
org.eclipse.core.internal.resources.ResourceException: A resource exists with a different case: '/local/FLD'.
	at org.eclipse.core.internal.resources.Resource.checkDoesNotExist(Resource.java:305)
	at org.eclipse.core.internal.resources.Resource.checkDoesNotExist(Resource.java:283)
	at org.eclipse.core.internal.resources.Folder.assertCreateRequirements(Folder.java:29)
	at org.eclipse.core.internal.resources.Folder.create(Folder.java:88)
	at org.eclipse.core.internal.resources.Folder.create(Folder.java:118)
	at org.eclipse.rse.internal.importexport.files.RemoteFileImportOperation.createContainersFor(RemoteFileImportOperation.java:220)
	at org.eclipse.rse.internal.importexport.files.RemoteFileImportOperation.getDestinationContainerFor(RemoteFileImportOperation.java:410)
	at org.eclipse.rse.internal.importexport.files.RemoteFileImportOperation.importFile(RemoteFileImportOperation.java:464)
	at org.eclipse.rse.internal.importexport.files.RemoteFileImportOperation.importRecursivelyFrom(RemoteFileImportOperation.java:616)
	at org.eclipse.rse.internal.importexport.files.RemoteFileImportOperation.importFileSystemObjects(RemoteFileImportOperation.java:558)
	at org.eclipse.rse.internal.importexport.files.RemoteFileImportOperation.execute(RemoteFileImportOperation.java:305)
	at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:104)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
	at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:116)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)


> Did you also try folder ("fld") versus file ("FLD") ?
> 

If we have a file ("FLD"), then the same exception is hit.


Comment 16 Martin Oberhuber CLA 2009-06-04 15:25:06 EDT
Interesting. Thanks for investigating!