Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 192850 Details for
Bug 278402
[Import/Export] Export project does not export empty folders
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch 3
patch zip.txt (text/plain), 11.65 KB, created by
Oleg Besedin
on 2011-04-08 11:39:19 EDT
(
hide
)
Description:
Patch 3
Filename:
MIME Type:
Creator:
Oleg Besedin
Created:
2011-04-08 11:39:19 EDT
Size:
11.65 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.ide >Index: src/org/eclipse/ui/internal/wizards/datatransfer/ArchiveFileExportOperation.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/ArchiveFileExportOperation.java,v >retrieving revision 1.10 >diff -u -r1.10 ArchiveFileExportOperation.java >--- src/org/eclipse/ui/internal/wizards/datatransfer/ArchiveFileExportOperation.java 1 Jun 2010 19:22:30 -0000 1.10 >+++ src/org/eclipse/ui/internal/wizards/datatransfer/ArchiveFileExportOperation.java 8 Apr 2011 15:32:41 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 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 >@@ -162,6 +162,20 @@ > throws InterruptedException { > exportResource(exportResource, 1); > } >+ >+ /** >+ * Creates and returns the string that should be used as the name of the entry in the archive. >+ * @param exportResource the resource to export >+ * @param leadupDepth the number of resource levels to be included in the path including the resourse itself. >+ */ >+ private String createDestinationName(int leadupDepth, IResource exportResource) { >+ IPath fullPath = exportResource.getFullPath(); >+ if (createLeadupStructure) { >+ return fullPath.makeRelative().toString(); >+ } >+ return fullPath.removeFirstSegments( >+ fullPath.segmentCount() - leadupDepth).toString(); >+ } > > /** > * Export the passed resource to the destination .zip >@@ -177,14 +191,7 @@ > } > > if (exportResource.getType() == IResource.FILE) { >- String destinationName; >- IPath fullPath = exportResource.getFullPath(); >- if (createLeadupStructure) { >- destinationName = fullPath.makeRelative().toString(); >- } else { >- destinationName = fullPath.removeFirstSegments( >- fullPath.segmentCount() - leadupDepth).toString(); >- } >+ String destinationName = createDestinationName(leadupDepth, exportResource); > monitor.subTask(destinationName); > > try { >@@ -206,6 +213,15 @@ > // this should never happen because an #isAccessible check is done before #members is invoked > addError(NLS.bind(DataTransferMessages.DataTransfer_errorExporting, exportResource.getFullPath()), e); > } >+ >+ if (children.length == 0) { // create an entry for empty containers, see bug 278402 >+ String destinationName = createDestinationName(leadupDepth, exportResource); >+ try { >+ exporter.write((IContainer) exportResource, destinationName + IPath.SEPARATOR); >+ } catch (IOException e) { >+ addError(NLS.bind(DataTransferMessages.DataTransfer_errorExporting, exportResource.getFullPath().makeRelative(), e.getMessage()), e); >+ } >+ } > > for (int i = 0; i < children.length; i++) { > exportResource(children[i], leadupDepth + 1); >#P org.eclipse.ui.tests >Index: Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ExportArchiveFileOperationTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ExportArchiveFileOperationTest.java,v >retrieving revision 1.7 >diff -u -r1.7 ExportArchiveFileOperationTest.java >--- Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ExportArchiveFileOperationTest.java 3 Nov 2009 10:35:38 -0000 1.7 >+++ Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ExportArchiveFileOperationTest.java 8 Apr 2011 15:32:41 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2009 IBM Corporation and others. >+ * Copyright (c) 2005, 2011 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 >@@ -36,6 +36,7 @@ > import org.eclipse.ui.dialogs.IOverwriteQuery; > import org.eclipse.ui.internal.wizards.datatransfer.ArchiveFileExportOperation; > import org.eclipse.ui.internal.wizards.datatransfer.TarEntry; >+import org.eclipse.ui.internal.wizards.datatransfer.TarException; > import org.eclipse.ui.internal.wizards.datatransfer.TarFile; > import org.eclipse.ui.tests.harness.util.FileUtil; > import org.eclipse.ui.tests.harness.util.UITestCase; >@@ -47,6 +48,7 @@ > private static final String ZIP_FILE_EXT = "zip"; > private static final String TAR_FILE_EXT = "tar"; > private static final String[] directoryNames = { "dir1", "dir2" }; >+ private static final String[] emptyDirectoryNames = { "dir3" }; > private static final String[] fileNames = { "file1.txt", "file2.txt" }; > > private String localDirectory; >@@ -84,9 +86,9 @@ > > operation.setUseCompression(false); > operation.setUseTarFormat(false); >- openTestWindow().run(true, true, operation); >+ operation.run(new NullProgressMonitor()); > >- verifyFolders(directoryNames.length, ZIP_FILE_EXT); >+ verifyFolders(directoryNames.length + emptyDirectoryNames.length, ZIP_FILE_EXT); > > } > >@@ -99,7 +101,7 @@ > > operation.setUseCompression(true); > operation.setUseTarFormat(false); >- openTestWindow().run(true, true, operation); >+ operation.run(new NullProgressMonitor()); > verifyCompressed(ZIP_FILE_EXT); > } > >@@ -123,9 +125,9 @@ > operation.setCreateLeadupStructure(false); > operation.setUseCompression(false); > operation.setUseTarFormat(false); >- openTestWindow().run(true, true, operation); >+ operation.run(new NullProgressMonitor()); > flattenPaths = true; >- verifyFolders(directoryNames.length, ZIP_FILE_EXT); >+ verifyFolders(directoryNames.length + emptyDirectoryNames.length, ZIP_FILE_EXT); > } > > public void testExportZipCreateSelectedDirectoriesWithFolders() throws Exception { >@@ -142,9 +144,9 @@ > operation.setCreateLeadupStructure(false); > operation.setUseCompression(false); > operation.setUseTarFormat(false); >- openTestWindow().run(true, true, operation); >+ operation.run(new NullProgressMonitor()); > excludeProjectPath = true; >- verifyFolders(directoryNames.length, ZIP_FILE_EXT); >+ verifyFolders(directoryNames.length + emptyDirectoryNames.length, ZIP_FILE_EXT); > } > > public void testExportZipCreateSelectedDirectoriesCompressed() throws Exception { >@@ -167,10 +169,10 @@ > operation.setCreateLeadupStructure(false); > operation.setUseCompression(true); > operation.setUseTarFormat(false); >- openTestWindow().run(true, true, operation); >+ operation.run(new NullProgressMonitor()); > flattenPaths = true; > verifyCompressed(ZIP_FILE_EXT); >- verifyFolders(directoryNames.length, ZIP_FILE_EXT); >+ verifyFolders(directoryNames.length + emptyDirectoryNames.length, ZIP_FILE_EXT); > } > > public void testExportTar() throws Exception { >@@ -182,9 +184,9 @@ > operation.setUseTarFormat(true); > operation.setUseCompression(false); > >- openTestWindow().run(true, true, operation); >+ operation.run(new NullProgressMonitor()); > >- verifyFolders(directoryNames.length, TAR_FILE_EXT); >+ verifyFolders(directoryNames.length + emptyDirectoryNames.length, TAR_FILE_EXT); > } > > public void testExportTarCompressed() throws Exception { >@@ -196,7 +198,7 @@ > > operation.setUseTarFormat(true); > operation.setUseCompression(true); >- openTestWindow().run(true, true, operation); >+ operation.run(new NullProgressMonitor()); > verifyCompressed(TAR_FILE_EXT); > } > >@@ -220,9 +222,9 @@ > operation.setCreateLeadupStructure(false); > operation.setUseCompression(false); > operation.setUseTarFormat(true); >- openTestWindow().run(true, true, operation); >+ operation.run(new NullProgressMonitor()); > flattenPaths = true; >- verifyFolders(directoryNames.length, TAR_FILE_EXT); >+ verifyFolders(directoryNames.length + emptyDirectoryNames.length, TAR_FILE_EXT); > } > > public void testExportTarCreateSelectedDirectoriesWithFolders() throws Exception { >@@ -239,9 +241,9 @@ > operation.setCreateLeadupStructure(false); > operation.setUseCompression(false); > operation.setUseTarFormat(true); >- openTestWindow().run(true, true, operation); >+ operation.run(new NullProgressMonitor()); > excludeProjectPath = true; >- verifyFolders(directoryNames.length, TAR_FILE_EXT); >+ verifyFolders(directoryNames.length + emptyDirectoryNames.length, TAR_FILE_EXT); > > } > >@@ -265,10 +267,10 @@ > operation.setCreateLeadupStructure(false); > operation.setUseCompression(true); > operation.setUseTarFormat(true); >- openTestWindow().run(true, true, operation); >+ operation.run(new NullProgressMonitor()); > flattenPaths = true; > verifyCompressed(TAR_FILE_EXT); >- verifyFolders(directoryNames.length, TAR_FILE_EXT); >+ verifyFolders(directoryNames.length + emptyDirectoryNames.length, TAR_FILE_EXT); > > } > >@@ -324,6 +326,12 @@ > true, new NullProgressMonitor()); > } > } >+ >+ // create empty folders to test bug 278402 >+ for(int i = 0; i < emptyDirectoryNames.length; i++){ >+ IFolder folder = project.getFolder(emptyDirectoryNames[i]); >+ folder.create(false, true, new NullProgressMonitor()); >+ } > } > catch(Exception e){ > fail(e.toString()); >@@ -358,7 +366,7 @@ > in.close(); > } > } >- catch (Exception e){ >+ catch (IOException e){ > fail(e.getMessage()); > } > assertTrue(fileName + " does not appear to be compressed.", compressed); >@@ -390,7 +398,10 @@ > else > verifyArchive(folderCount, allEntries); > } >- catch (Exception e){ >+ catch (IOException e){ >+ fail(e.getMessage()); >+ } >+ catch (TarException e){ > fail(e.getMessage()); > } > } >@@ -405,7 +416,10 @@ > int idx = entryName.lastIndexOf("/"); > String folderPath = entryName.substring(0, idx); > String fileName = entryName.substring(idx+1, entryName.length()); >- files.add(fileName); >+ // we get empty strings for folder entries, don't add them as a file name >+ if (fileName.length() != 0) { >+ files.add(fileName); >+ } > int idx2 = folderPath.lastIndexOf("/"); > if (idx2 != -1){ > String folderName = folderPath.substring(idx2 + 1, folderPath.length()); >@@ -461,15 +475,15 @@ > if (directoryNames[i].equals(name)) > return true; > } >+ for (int i = 0; i < emptyDirectoryNames.length; i++){ >+ if (emptyDirectoryNames[i].equals(name)) >+ return true; >+ } > return false; > } > > private boolean isDirectory(IResource resource){ >- for (int i = 0; i < directoryNames.length; i++){ >- if (directoryNames[i].equals(resource.getName())) >- return true; >- } >- return false; >+ return isDirectory(resource.getName()); > } > > private boolean isFile(IResource resource){
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 278402
:
137765
|
149468
|
188350
| 192850