mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 14:55:41 +02:00
[191370] fix: [dstore] Supertransfer zip not deleted when cancelling copy
This commit is contained in:
parent
a4e1f81b69
commit
877d847b6d
3 changed files with 54 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved.
|
||||
* Copyright (c) 2006, 2008 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 http://www.eclipse.org/legal/epl-v10.html
|
||||
|
@ -1969,7 +1969,18 @@ public class UniversalFileTransferUtility
|
|||
IRemoteFile sourceDir = sourceFS.getRemoteFileObject(directory.getAbsolutePath(), monitor);
|
||||
|
||||
// DKM - copy src dir to remote temp archive
|
||||
sourceFS.copy(sourceDir, destinationArchive, sourceDir.getName(), monitor);
|
||||
try
|
||||
{
|
||||
sourceFS.copy(sourceDir, destinationArchive, sourceDir.getName(), monitor);
|
||||
}
|
||||
catch (SystemMessageException e)
|
||||
{
|
||||
if (monitor.isCanceled())
|
||||
{
|
||||
cleanup(destinationArchive, null);
|
||||
return targetResource;
|
||||
}
|
||||
}
|
||||
destinationArchive.markStale(true);
|
||||
|
||||
// reget it so that it's properties (namely "size") are correct
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2003, 2007 IBM Corporation and others.
|
||||
* Copyright (c) 2003, 2008 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
|
||||
|
@ -21,6 +21,7 @@
|
|||
* Xuan Chen (IBM) - [211551] NPE when moving multiple folders from one tar file to another tar file
|
||||
* Xuan Chen (IBM) - [211653] Copy virtual directory with nested directory of tar file did not work
|
||||
* Xuan Chen (IBM) - [214251] [archive] "Last Modified Time" changed for all virtual files/folders if rename/paste/delete of one virtual file.
|
||||
* Xuan Chen (IBM) - [191370] [dstore] Supertransfer zip not deleted when cancelling copy
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.clientserver.archiveutils;
|
||||
|
@ -1248,10 +1249,19 @@ public class SystemTarHandler implements ISystemArchiveHandler {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
VirtualChild[] newEntriesAdded = new VirtualChild[numFiles];
|
||||
// for each new file to add
|
||||
for (int i = 0; i < numFiles; i++) {
|
||||
|
||||
if (archiveOperationMonitor != null && archiveOperationMonitor.isCanceled())
|
||||
{
|
||||
outStream.close();
|
||||
if (outputTempFile != null)
|
||||
{
|
||||
outputTempFile.delete();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
String childVirtualPath = virtualPath + "/" + names[i]; //$NON-NLS-1$
|
||||
|
||||
TarEntry newEntry = createTarEntry(files[i], childVirtualPath);
|
||||
|
@ -1261,15 +1271,22 @@ public class SystemTarHandler implements ISystemArchiveHandler {
|
|||
|
||||
// add the new entry to the cache, so that the cache is updated
|
||||
VirtualChild temp = getVirtualChild(newEntry);
|
||||
vfs.addEntry(temp);
|
||||
newEntriesAdded[i] = temp;
|
||||
}
|
||||
|
||||
|
||||
// close output stream
|
||||
outStream.close();
|
||||
|
||||
// replace the current tar file with the new one, and do not update cache since
|
||||
// we just did
|
||||
replaceFile(outputTempFile, false);
|
||||
|
||||
//Also need to add the new entries into VFS
|
||||
for (int i = 0; i < numFiles; i++)
|
||||
{
|
||||
vfs.addEntry(newEntriesAdded[i]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
* Xuan Chen (IBM) - [191370] [dstore] Supertransfer zip not deleted when cancelling copy
|
||||
* Xuan Chen (IBM) - [214251] [archive] "Last Modified Time" changed for all virtual files/folders if rename/paste/delete of one virtual file.
|
||||
* Xuan Chen (IBM) - [214786] [regression][archive]rename a virtual directory does not work properly
|
||||
* Xuan Chen (IBM) - [191370] [dstore] Supertransfer zip not deleted when cancelling copy
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.clientserver.archiveutils;
|
||||
|
@ -1285,33 +1286,47 @@ public class SystemZipHandler implements ISystemArchiveHandler
|
|||
if (isCanceled)
|
||||
{
|
||||
dest.close();
|
||||
if (!(outputTempFile == null)) outputTempFile.delete();
|
||||
if (!(outputTempFile == null))
|
||||
{
|
||||
outputTempFile.delete();
|
||||
}
|
||||
if (closeZipFile) closeZipFile();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Now for each new file to add
|
||||
// We need to remember the entries added, and if this operation is not canceled, we
|
||||
// will add them into Virtual File system.
|
||||
ZipEntry[] newEntriesAdded = new ZipEntry[numFiles];
|
||||
for (int i = 0; i < numFiles; i++)
|
||||
{
|
||||
if (archiveOperationMonitor != null && archiveOperationMonitor.isCanceled())
|
||||
{
|
||||
if (archiveOperationMonitor != null && archiveOperationMonitor.isCanceled())
|
||||
{
|
||||
//the operation has been canceled
|
||||
dest.close();
|
||||
if (!(outputTempFile == null))
|
||||
{
|
||||
outputTempFile.delete();
|
||||
}
|
||||
closeZipFile();
|
||||
return false;
|
||||
}
|
||||
// append the additional entry to the zip file.
|
||||
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
|
||||
fillBranch(newEntry);
|
||||
// Add the new entry to the array first.
|
||||
newEntriesAdded[i] = newEntry;
|
||||
}
|
||||
|
||||
dest.close();
|
||||
|
||||
// Now replace the old zip file with the new one
|
||||
replaceOldZip(outputTempFile);
|
||||
|
||||
//Also need to add the new entries into VFS
|
||||
for (int i = 0; i < numFiles; i++)
|
||||
{
|
||||
fillBranch(newEntriesAdded[i]);
|
||||
}
|
||||
|
||||
if (closeZipFile) closeZipFile();
|
||||
return true;
|
||||
|
|
Loading…
Add table
Reference in a new issue