mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-05 07:15:39 +02:00
[191370] fix: [dstore] Supertransfer zip not deleted when cancelling copy
This commit is contained in:
parent
a7be65e084
commit
66d9007048
4 changed files with 103 additions and 15 deletions
|
@ -37,6 +37,7 @@
|
||||||
* David Mcknight (IBM) - [203114] don't treat XML files specially (no hidden prefs for bin vs text)
|
* David Mcknight (IBM) - [203114] don't treat XML files specially (no hidden prefs for bin vs text)
|
||||||
* David McKnight (IBM) - [209552] get rid of copy APIs to be clearer with download and upload
|
* David McKnight (IBM) - [209552] get rid of copy APIs to be clearer with download and upload
|
||||||
* David McKnight (IBM) - [143503] encoding and isBinary needs to be stored in the IFile properties
|
* David McKnight (IBM) - [143503] encoding and isBinary needs to be stored in the IFile properties
|
||||||
|
* Xuan Chen (IBM) - [191370] [dstore] Supertransfer zip not deleted when cancelling copy
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.files.ui.resources;
|
package org.eclipse.rse.files.ui.resources;
|
||||||
|
@ -1283,6 +1284,19 @@ public class UniversalFileTransferUtility
|
||||||
{
|
{
|
||||||
if (monitor != null && monitor.isCanceled())
|
if (monitor != null && monitor.isCanceled())
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IRemoteFile[] results = targetFS.getRemoteFileObjects((String[])newFilePathList.toArray(new String[newFilePathList.size()]), monitor);
|
||||||
|
resultSet = new SystemRemoteResourceSet(targetFS, results);
|
||||||
|
if (workspaceSet.hasMessage())
|
||||||
|
{
|
||||||
|
resultSet.setMessage(workspaceSet.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
return resultSet;
|
return resultSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1450,7 +1464,7 @@ public class UniversalFileTransferUtility
|
||||||
}
|
}
|
||||||
catch (SystemMessageException e)
|
catch (SystemMessageException e)
|
||||||
{
|
{
|
||||||
SystemMessageDialog.displayMessage(e);
|
workspaceSet.setMessage(e.getSystemMessage());
|
||||||
}
|
}
|
||||||
catch (CoreException e)
|
catch (CoreException e)
|
||||||
{
|
{
|
||||||
|
@ -1468,6 +1482,10 @@ public class UniversalFileTransferUtility
|
||||||
{
|
{
|
||||||
IRemoteFile[] results = targetFS.getRemoteFileObjects((String[])newFilePathList.toArray(new String[newFilePathList.size()]), monitor);
|
IRemoteFile[] results = targetFS.getRemoteFileObjects((String[])newFilePathList.toArray(new String[newFilePathList.size()]), monitor);
|
||||||
resultSet = new SystemRemoteResourceSet(targetFS, results);
|
resultSet = new SystemRemoteResourceSet(targetFS, results);
|
||||||
|
if (workspaceSet.hasMessage())
|
||||||
|
{
|
||||||
|
resultSet.setMessage(workspaceSet.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -1730,6 +1748,9 @@ public class UniversalFileTransferUtility
|
||||||
}
|
}
|
||||||
IRemoteFile destinationArchive = null;
|
IRemoteFile destinationArchive = null;
|
||||||
String newPath = null;
|
String newPath = null;
|
||||||
|
IRemoteFileSubSystem targetFS = null;
|
||||||
|
IRemoteFile remoteArchive = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
monitor.beginTask(FileResources.RESID_SUPERTRANSFER_PROGMON_MAIN,IProgressMonitor.UNKNOWN);
|
monitor.beginTask(FileResources.RESID_SUPERTRANSFER_PROGMON_MAIN,IProgressMonitor.UNKNOWN);
|
||||||
|
@ -1757,7 +1778,7 @@ public class UniversalFileTransferUtility
|
||||||
IRemoteFile newTargetParent = newTargetFolder.getParentRemoteFile();
|
IRemoteFile newTargetParent = newTargetFolder.getParentRemoteFile();
|
||||||
monitor.subTask(FileResources.RESID_SUPERTRANSFER_PROGMON_SUBTASK_POPULATE);
|
monitor.subTask(FileResources.RESID_SUPERTRANSFER_PROGMON_SUBTASK_POPULATE);
|
||||||
IRemoteFile sourceDir = localSS.getRemoteFileObject(directory.getLocation().toOSString(), monitor);
|
IRemoteFile sourceDir = localSS.getRemoteFileObject(directory.getLocation().toOSString(), monitor);
|
||||||
IRemoteFileSubSystem targetFS = newTargetFolder.getParentRemoteFileSubSystem();
|
targetFS = newTargetFolder.getParentRemoteFileSubSystem();
|
||||||
|
|
||||||
|
|
||||||
// FIXME
|
// FIXME
|
||||||
|
@ -1769,7 +1790,7 @@ public class UniversalFileTransferUtility
|
||||||
|
|
||||||
// copy local zip to remote
|
// copy local zip to remote
|
||||||
targetFS.upload(destinationArchive.getAbsolutePath(), SystemEncodingUtil.ENCODING_UTF_8, newPath, System.getProperty("file.encoding"), monitor); //$NON-NLS-1$
|
targetFS.upload(destinationArchive.getAbsolutePath(), SystemEncodingUtil.ENCODING_UTF_8, newPath, System.getProperty("file.encoding"), monitor); //$NON-NLS-1$
|
||||||
IRemoteFile remoteArchive = targetFS.getRemoteFileObject(newPath, monitor);
|
remoteArchive = targetFS.getRemoteFileObject(newPath, monitor);
|
||||||
|
|
||||||
monitor.subTask(FileResources.RESID_SUPERTRANSFER_PROGMON_SUBTASK_EXTRACT);
|
monitor.subTask(FileResources.RESID_SUPERTRANSFER_PROGMON_SUBTASK_EXTRACT);
|
||||||
String compressedFolderPath = newPath + ArchiveHandlerManager.VIRTUAL_SEPARATOR + directory.getName();
|
String compressedFolderPath = newPath + ArchiveHandlerManager.VIRTUAL_SEPARATOR + directory.getName();
|
||||||
|
@ -1777,20 +1798,21 @@ public class UniversalFileTransferUtility
|
||||||
|
|
||||||
// extract the compressed folder from the temp archive on remote
|
// extract the compressed folder from the temp archive on remote
|
||||||
targetFS.copy(compressedFolder, newTargetParent, newTargetFolder.getName(), monitor);
|
targetFS.copy(compressedFolder, newTargetParent, newTargetFolder.getName(), monitor);
|
||||||
|
|
||||||
// delete the temp remote archive
|
|
||||||
// now, DStoreFileService#getFile() (which is invoked by getRemoteFileObject() call)
|
|
||||||
// has been updated to also put the query object into the dstore file map,
|
|
||||||
// we don't need to do the query on the remoteArchive object before the
|
|
||||||
// delete.
|
|
||||||
targetFS.delete(remoteArchive, monitor);
|
|
||||||
|
|
||||||
monitor.done();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (SystemMessageException e)
|
catch (SystemMessageException e)
|
||||||
{
|
{
|
||||||
SystemMessageDialog.displayMessage(e);
|
if (monitor.isCanceled())
|
||||||
|
{
|
||||||
|
//If this operation if canceled, and if the destination has already been created (partially)
|
||||||
|
//in the host, we need to delete it.
|
||||||
|
if (newTargetFolder.exists())
|
||||||
|
{
|
||||||
|
targetFS.delete(newTargetFolder, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
//SystemMessageDialog.displayMessage(e);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -1800,6 +1822,17 @@ public class UniversalFileTransferUtility
|
||||||
finally {
|
finally {
|
||||||
if (newPath == null) cleanup(destinationArchive, null);
|
if (newPath == null) cleanup(destinationArchive, null);
|
||||||
else cleanup(destinationArchive, new File(newPath));
|
else cleanup(destinationArchive, new File(newPath));
|
||||||
|
|
||||||
|
// delete the temp remote archive
|
||||||
|
// now, DStoreFileService#getFile() (which is invoked by getRemoteFileObject() call)
|
||||||
|
// has been updated to also put the query object into the dstore file map,
|
||||||
|
// we don't need to do the query on the remoteArchive object before the
|
||||||
|
// delete.
|
||||||
|
if (remoteArchive != null && remoteArchive.exists())
|
||||||
|
{
|
||||||
|
targetFS.delete(remoteArchive, null);
|
||||||
|
}
|
||||||
|
monitor.done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
* David McKnight (IBM) - [209660] need to check if remote encoding has changed before using cached file
|
* David McKnight (IBM) - [209660] need to check if remote encoding has changed before using cached file
|
||||||
* Xuan Chen (IBM) - [160775] [api] [breaking] [nl] rename (at least within a zip) blocks UI thread
|
* Xuan Chen (IBM) - [160775] [api] [breaking] [nl] rename (at least within a zip) blocks UI thread
|
||||||
* Xuan Chen (IBM) - [209827] Update DStore command implementation to enable cancelation of archive operations
|
* Xuan Chen (IBM) - [209827] Update DStore command implementation to enable cancelation of archive operations
|
||||||
|
* Xuan Chen (IBM) - [191370] [dstore] Supertransfer zip not deleted when cancelling copy
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.files.ui.view;
|
package org.eclipse.rse.internal.files.ui.view;
|
||||||
|
@ -1844,12 +1845,42 @@ public class SystemViewRemoteFileAdapter
|
||||||
monitor.beginTask(_uploadMessage.getLevelOneText(), size);
|
monitor.beginTask(_uploadMessage.getLevelOneText(), size);
|
||||||
}
|
}
|
||||||
// back to hierarchy
|
// back to hierarchy
|
||||||
return UniversalFileTransferUtility.uploadResourcesFromWorkspace((SystemWorkspaceResourceSet)fromSet, targetFolder, monitor, true);
|
resultSet = UniversalFileTransferUtility.uploadResourcesFromWorkspace((SystemWorkspaceResourceSet)fromSet, targetFolder, monitor, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return UniversalFileTransferUtility.uploadResourcesFromWorkspace((SystemWorkspaceResourceSet)fromSet, targetFolder, monitor, true);
|
resultSet = UniversalFileTransferUtility.uploadResourcesFromWorkspace((SystemWorkspaceResourceSet)fromSet, targetFolder, monitor, true);
|
||||||
}
|
}
|
||||||
|
if (resultSet.hasMessage())
|
||||||
|
{
|
||||||
|
SystemMessage msg = resultSet.getMessage();
|
||||||
|
if (monitor.isCanceled() && resultSet.size() > 0)
|
||||||
|
{
|
||||||
|
//Get the moved file names
|
||||||
|
Object thisObject = resultSet.get(0);
|
||||||
|
String copiedFileNames = null;
|
||||||
|
if (thisObject instanceof IRemoteFile)
|
||||||
|
{
|
||||||
|
copiedFileNames = ((IRemoteFile)thisObject).getName();
|
||||||
|
for (int i=1; i<(resultSet.size()); i++)
|
||||||
|
{
|
||||||
|
if (thisObject instanceof IRemoteFile)
|
||||||
|
{
|
||||||
|
copiedFileNames = copiedFileNames + "\n" + ((IRemoteFile)thisObject).getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//getMessage("RSEG1125").makeSubstitution(movedFileName));
|
||||||
|
if (copiedFileNames != null)
|
||||||
|
{
|
||||||
|
SystemMessage thisMessage = RSEUIPlugin.getPluginMessage(ISystemMessages.FILEMSG_COPY_INTERRUPTED);
|
||||||
|
thisMessage.makeSubstitution(copiedFileNames);
|
||||||
|
resultSet.setMessage(thisMessage);
|
||||||
|
//SystemMessageDialog.displayErrorMessage(shell, thisMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultSet;
|
||||||
}
|
}
|
||||||
else if (fromSet instanceof SystemRemoteResourceSet)
|
else if (fromSet instanceof SystemRemoteResourceSet)
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
* Xuan Chen (IBM) - [181784] [archivehandlers] zipped text files have unexpected contents
|
* Xuan Chen (IBM) - [181784] [archivehandlers] zipped text files have unexpected contents
|
||||||
* Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
|
* Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
|
||||||
* Xuan Chen (IBM) - [209828] Need to move the Create operation to a job.
|
* Xuan Chen (IBM) - [209828] Need to move the Create operation to a job.
|
||||||
|
* Xuan Chen (IBM) - [191370] [dstore] Supertransfer zip not deleted when cancelling copy
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.services.clientserver.archiveutils;
|
package org.eclipse.rse.services.clientserver.archiveutils;
|
||||||
|
@ -1008,6 +1009,12 @@ public class SystemZipHandler implements ISystemArchiveHandler
|
||||||
int numFiles = files.length;
|
int numFiles = files.length;
|
||||||
for (int i = 0; i < numFiles; i++)
|
for (int i = 0; i < numFiles; i++)
|
||||||
{
|
{
|
||||||
|
if (archiveOperationMonitor != null && archiveOperationMonitor.isCanceled())
|
||||||
|
{
|
||||||
|
//the operation has been canceled
|
||||||
|
closeZipFile();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (!files[i].exists() || !files[i].canRead()) return false;
|
if (!files[i].exists() || !files[i].canRead()) return false;
|
||||||
String fullVirtualName = getFullVirtualName(virtualPath, names[i]);
|
String fullVirtualName = getFullVirtualName(virtualPath, names[i]);
|
||||||
if (exists(fullVirtualName, archiveOperationMonitor))
|
if (exists(fullVirtualName, archiveOperationMonitor))
|
||||||
|
@ -1043,6 +1050,13 @@ public class SystemZipHandler implements ISystemArchiveHandler
|
||||||
// Now for each new file to add
|
// Now for each new file to add
|
||||||
for (int i = 0; i < numFiles; i++)
|
for (int i = 0; i < numFiles; i++)
|
||||||
{
|
{
|
||||||
|
if (archiveOperationMonitor != null && archiveOperationMonitor.isCanceled())
|
||||||
|
{
|
||||||
|
//the operation has been canceled
|
||||||
|
dest.close();
|
||||||
|
closeZipFile();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// append the additional entry to the zip file.
|
// append the additional entry to the zip file.
|
||||||
ZipEntry newEntry = appendFile(files[i], dest, virtualPath, names[i], sourceEncodings[i], targetEncodings[i], isText[i]);
|
ZipEntry newEntry = appendFile(files[i], dest, virtualPath, names[i], sourceEncodings[i], targetEncodings[i], isText[i]);
|
||||||
// Add the new entry to the virtual file system in memory
|
// Add the new entry to the virtual file system in memory
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
* Rupen Mardirossian (IBM) - [187713] Check to see if target is null before attempting to retrieve targetAdapter in tranferRSEResources method (line 248)
|
* Rupen Mardirossian (IBM) - [187713] Check to see if target is null before attempting to retrieve targetAdapter in tranferRSEResources method (line 248)
|
||||||
* Martin Oberhuber (Wind River) - [200682] Fix drag&drop for elements just adaptable to IResource, like CDT elements
|
* Martin Oberhuber (Wind River) - [200682] Fix drag&drop for elements just adaptable to IResource, like CDT elements
|
||||||
* David McKnight (IBM) - [186363] get rid of obsolete calls to SubSystem.connect()
|
* David McKnight (IBM) - [186363] get rid of obsolete calls to SubSystem.connect()
|
||||||
|
* Xuan Chen (IBM) - [191370] [dstore] Supertransfer zip not deleted when cancelling copy
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.ui.view;
|
package org.eclipse.rse.internal.ui.view;
|
||||||
|
@ -219,6 +220,15 @@ public class SystemDNDTransferRunnable extends WorkspaceJob
|
||||||
}
|
}
|
||||||
else if (droppedObjects.hasMessage())
|
else if (droppedObjects.hasMessage())
|
||||||
{
|
{
|
||||||
|
//Even the droppedObject has message, it could still has
|
||||||
|
//dropped results. (user cancels the operation, but some objects
|
||||||
|
//has already been copied.
|
||||||
|
//Need to make sure we refresh those copied object.
|
||||||
|
List results = droppedObjects.getResourceSet();
|
||||||
|
for (int d = 0; d < results.size(); d++)
|
||||||
|
{
|
||||||
|
_resultTgtObjects.add(results.get(d));
|
||||||
|
}
|
||||||
operationFailed(monitor);
|
operationFailed(monitor);
|
||||||
showErrorMessage(droppedObjects.getMessage());
|
showErrorMessage(droppedObjects.getMessage());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue