Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 278402

Summary: [Import/Export] Export project does not export empty folders
Product: [Eclipse Project] Platform Reporter: Andrew Mak <makandre>
Component: IDEAssignee: Oleg Besedin <ob1.eclipse>
Status: VERIFIED FIXED QA Contact: Prakash Rangaraj <prakash>
Severity: normal    
Priority: P3 CC: achapiro, alicec, bjustin, bokowski, cbridgha, ccc, daniel_megert, devel, edwinc, gdtaylor, give.a.damus, hsoliwal, ob1.eclipse, pkashyap, pwebster, remy.suen, rtaniwa, tdramsey, zalapa
Version: 3.5Keywords: helpwanted
Target Milestone: 3.7 M7   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 342308, 358470    
Attachments:
Description Flags
Export wizard patch v1
none
ExportArchiveFileOperationTest patch v1
none
patch_for_3.6_maintenance
none
Patch 3 none

Description Andrew Mak CLA 2009-05-29 10:55:31 EDT
I have a project with an empty folder in it, which I exported to a zip file using the standard "Export > General > Archive File" method.

I subsequently imported that project into another workspace using "Import > Genearal > Existing Projects into Workspace" method.  The resulting project does not have the empty folder that was in the original project.

This is a problem especially for Java projects with empty src folder, because after importing there will be an error saying the src folder is missing.
Comment 1 Remy Suen CLA 2009-05-29 13:10:41 EDT
Does the folder physically exist within the zip file?
Comment 2 Andrew Mak CLA 2009-05-29 13:24:44 EDT
The folder does not exist in the zip, even though it was checked when I exported the project.
Comment 3 Remy Suen CLA 2009-05-29 13:27:38 EDT
Sounds like a problem with our export wizard. Andrew, which build are you using? Can you consistently reproduce this?
Comment 4 Andrew Mak CLA 2009-05-29 13:32:28 EDT
Yes, it can be consistently reproduced.  I'm using 3.5 RC2 stable build (S-3.5RC2-200905221710)
Comment 5 Paul Webster CLA 2009-05-29 13:37:25 EDT
It looks like we don't add the directory to the exported zip.

What about a zip that does include the directory?

PW
Comment 6 Andrew Mak CLA 2009-05-29 13:46:00 EDT
If zip has the directory, then the directory gets created on import.
Comment 7 Remy Suen CLA 2009-05-30 21:32:56 EDT
Created attachment 137765 [details]
Export wizard patch v1

Both zip and tar exports suffers from the same problem. I updated the tests to include an empty folder. I also took the liberty of not changing the tests to not use an IWorkbenchWindow to perform the operation since it seems to serve no purpose (besides wasting time).
Comment 8 Prakash Rangaraj CLA 2009-06-01 08:52:46 EDT
*** Bug 208672 has been marked as a duplicate of this bug. ***
Comment 9 Grant Taylor CLA 2009-09-30 15:27:32 EDT
We are hitting the same issue.  We are on version 3.4.2 of Eclipse.  The exact same major issue is hit with our customers.  They export a Java project (in our case, a Web project from WST), then they re-import it to discover that there are errors now.
Comment 10 Prakash Rangaraj CLA 2009-10-08 02:51:54 EDT
Patch v01 released to HEAD
Comment 11 Oleg Besedin CLA 2009-10-13 13:49:22 EDT
This change cases failure of serveral JUnits from the ExportArchiveFileOperationTest class on Windows machines:

private void verifyArchive(int folderCount, List entries){
....
String entryName = (String)archiveEntries.next(); <= "ExporttestExportZip\"
int idx = entryName.lastIndexOf("/");			<= idx = -1
String folderPath = entryName.substring(0, idx);	<= Exception

The directories end with backslash ("\") rather then forward slash ("/") which seems to be expected.
Comment 12 Remy Suen CLA 2009-10-13 15:28:35 EDT
Created attachment 149468 [details]
ExportArchiveFileOperationTest patch v1

(In reply to comment #11)
> This change cases failure of serveral JUnits from the
> ExportArchiveFileOperationTest class on Windows machines:
> 
> private void verifyArchive(int folderCount, List entries){
> ....
> String entryName = (String)archiveEntries.next(); <= "ExporttestExportZip\"
> int idx = entryName.lastIndexOf("/");            <= idx = -1
> String folderPath = entryName.substring(0, idx);    <= Exception
> 
> The directories end with backslash ("\") rather then forward slash ("/") which
> seems to be expected.

How embarassing. This patch should fix it up. I also took the liberty of changing the failed method to just throw the exception and propagate it to JUnit instead of failing on it. This gives us a proper stack trace in the 'JUnit' view whereas the other doesn't give us much.
Comment 13 Prakash Rangaraj CLA 2009-10-14 02:08:02 EDT
Hitesh,

   Can you test this patch on Windows machine?
Comment 14 Hitesh CLA 2009-10-14 06:27:01 EDT
(In reply to comment #13)
> Hitesh,
> 
>    Can you test this patch on Windows machine?

The patch fixes the tests on my XP machine.
Comment 15 Prakash Rangaraj CLA 2009-10-14 06:44:40 EDT
Thanks Remy & Hitesh.
The patch is checked into HEAD. Just in time for the N build :-)
Comment 16 Dani Megert CLA 2009-11-02 12:02:47 EST
I've reverted the fix as it is no good: it results in duplicate entries for directories and this lets the import fail badly afterwards.

1. export a Java project to an archive
2. delete the project
3. import
==> most files not imported (aborts due to duplicate dirs in archive)

See bug 293950 for the missing error reporting.
Comment 17 Oleg Besedin CLA 2009-11-02 15:57:43 EST
(In reply to comment #16)
> I've reverted the fix as it is no good

Do you need to revert JUnits as well? The following JUnits fail:

ExportArchiveFileOperationTest
 testExportZip
 testExportZipCreateSelectedDirectoriesWithFodlers
 testExportTar
 testExportTarCreateSelectedDirectoriesWithFodlers
Comment 18 Dani Megert CLA 2009-11-03 05:35:46 EST
Thanks for the reminder Oleg! I've updated and released the test for I20091103-0800.
Comment 19 Remy Suen CLA 2010-06-15 17:39:41 EDT
*** Bug 316964 has been marked as a duplicate of this bug. ***
Comment 20 Daniel Hirscher CLA 2010-07-28 04:30:33 EDT
The problem is still there on 3.6, I have done the following:

1. created a new project (simple project)
2. put some folders in it, in the following manner
- ExportTestProject
-- folder1
--- subfolder1
---- file1.txt
--- subfolder2
-- folder2
--- subfolder1
--- subfolder2
-- folder3
3. exported via archive wizard with default settings

The test shows that all empty folders (including folders with empty sub folders) are not exported. The resulting file only contains folder1/subfolder1/file1.txt and the .project file. Same result with tar.

I need all empty folders in the archive.
Comment 21 Francis Upton IV CLA 2010-10-11 14:00:39 EDT
*** Bug 326447 has been marked as a duplicate of this bug. ***
Comment 22 Robert Taniwa CLA 2010-11-16 12:21:02 EST
Seems like there has been a few dupes for this issue. Is there an outlook for a fix?
Comment 23 Theresa Ramsey CLA 2011-02-02 14:01:03 EST
This also impacts some Rational tools which are based on Eclipse. Users get errors on import since the empty folders are stripped off during export. This has caused customer confusion, and requires them to do a workaround.
Comment 24 Chuck Bridgham CLA 2011-02-04 14:00:23 EST
Created attachment 188350 [details]
patch_for_3.6_maintenance

I took a little time to investigate the earlier patches, and added some code to only create directory entries for empty directories.

My local testing with both zip and rar works great - can someone take a look and consider for next maintenance release?

this patch applies to R3_6_maintenance stream
Comment 25 Alice Connors CLA 2011-03-08 12:47:57 EST
Rational Business Developer (RBD) is anxious to have a fix for this problem on 3.6. (See Comment 23.) Is it possible to get a patch?
Comment 26 Justin Berstler CLA 2011-04-07 15:05:15 EDT
+1 on this fixing this promptly.  It's a major annoyance to manually patch up imported projects, especially when the missing folders are referenced in project metadata (e.g. classpath for Java projects).
Comment 27 Oleg Besedin CLA 2011-04-08 11:39:19 EDT
Created attachment 192850 [details]
Patch 3

To clarify the current state:

- Parts of Remy's patch (IFileExporter, ZipFileExporter, TarFileExporter) are released in Eclipse 3.6.0 and later versions;
- The changes to ArchiveFileExportOperation and tests were reversed by Dani.

This patch contains reversed parts of Remy's patch with some changes:
- we create extra entries only for containers with no children
- we use IPath.SEPARATOR
- updated try/catch blocks in tests to limit them to I/O exceptions
Comment 28 Oleg Besedin CLA 2011-04-08 11:43:10 EDT
Patch applied to CVS Head.
Comment 29 Oleg Besedin CLA 2011-04-08 11:50:15 EDT
I opened bug 342308 to consider back-porting this fix into 3.6.2+.
Comment 30 Dani Megert CLA 2011-04-12 11:02:52 EDT
Verified in N20110411-2000 that it works as expected. There's one small hole left in the story when it comes to importing (not as project), see bug 33171.
Comment 31 Carl Anderson CLA 2011-04-15 12:33:36 EDT
*** Bug 342758 has been marked as a duplicate of this bug. ***
Comment 32 Oleg Besedin CLA 2011-04-26 10:55:37 EDT
Verified in I20110425-1800.