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
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
|
* 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
|
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
@ -1969,7 +1969,18 @@ public class UniversalFileTransferUtility
|
||||||
IRemoteFile sourceDir = sourceFS.getRemoteFileObject(directory.getAbsolutePath(), monitor);
|
IRemoteFile sourceDir = sourceFS.getRemoteFileObject(directory.getAbsolutePath(), monitor);
|
||||||
|
|
||||||
// DKM - copy src dir to remote temp archive
|
// DKM - copy src dir to remote temp archive
|
||||||
|
try
|
||||||
|
{
|
||||||
sourceFS.copy(sourceDir, destinationArchive, sourceDir.getName(), monitor);
|
sourceFS.copy(sourceDir, destinationArchive, sourceDir.getName(), monitor);
|
||||||
|
}
|
||||||
|
catch (SystemMessageException e)
|
||||||
|
{
|
||||||
|
if (monitor.isCanceled())
|
||||||
|
{
|
||||||
|
cleanup(destinationArchive, null);
|
||||||
|
return targetResource;
|
||||||
|
}
|
||||||
|
}
|
||||||
destinationArchive.markStale(true);
|
destinationArchive.markStale(true);
|
||||||
|
|
||||||
// reget it so that it's properties (namely "size") are correct
|
// 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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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) - [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) - [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) - [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;
|
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 each new file to add
|
||||||
for (int i = 0; i < numFiles; i++) {
|
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$
|
String childVirtualPath = virtualPath + "/" + names[i]; //$NON-NLS-1$
|
||||||
|
|
||||||
TarEntry newEntry = createTarEntry(files[i], childVirtualPath);
|
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
|
// add the new entry to the cache, so that the cache is updated
|
||||||
VirtualChild temp = getVirtualChild(newEntry);
|
VirtualChild temp = getVirtualChild(newEntry);
|
||||||
vfs.addEntry(temp);
|
newEntriesAdded[i] = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// close output stream
|
// close output stream
|
||||||
outStream.close();
|
outStream.close();
|
||||||
|
|
||||||
// replace the current tar file with the new one, and do not update cache since
|
// replace the current tar file with the new one, and do not update cache since
|
||||||
// we just did
|
// we just did
|
||||||
replaceFile(outputTempFile, false);
|
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) - [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) - [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) - [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;
|
package org.eclipse.rse.services.clientserver.archiveutils;
|
||||||
|
@ -1285,33 +1286,47 @@ public class SystemZipHandler implements ISystemArchiveHandler
|
||||||
if (isCanceled)
|
if (isCanceled)
|
||||||
{
|
{
|
||||||
dest.close();
|
dest.close();
|
||||||
if (!(outputTempFile == null)) outputTempFile.delete();
|
if (!(outputTempFile == null))
|
||||||
|
{
|
||||||
|
outputTempFile.delete();
|
||||||
|
}
|
||||||
if (closeZipFile) closeZipFile();
|
if (closeZipFile) closeZipFile();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now for each new file to add
|
// 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++)
|
for (int i = 0; i < numFiles; i++)
|
||||||
{
|
{
|
||||||
if (archiveOperationMonitor != null && archiveOperationMonitor.isCanceled())
|
if (archiveOperationMonitor != null && archiveOperationMonitor.isCanceled())
|
||||||
{
|
{
|
||||||
//the operation has been canceled
|
//the operation has been canceled
|
||||||
dest.close();
|
dest.close();
|
||||||
|
if (!(outputTempFile == null))
|
||||||
|
{
|
||||||
|
outputTempFile.delete();
|
||||||
|
}
|
||||||
closeZipFile();
|
closeZipFile();
|
||||||
return false;
|
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 array first.
|
||||||
fillBranch(newEntry);
|
newEntriesAdded[i] = newEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
dest.close();
|
dest.close();
|
||||||
|
|
||||||
// Now replace the old zip file with the new one
|
// Now replace the old zip file with the new one
|
||||||
replaceOldZip(outputTempFile);
|
replaceOldZip(outputTempFile);
|
||||||
|
//Also need to add the new entries into VFS
|
||||||
|
for (int i = 0; i < numFiles; i++)
|
||||||
|
{
|
||||||
|
fillBranch(newEntriesAdded[i]);
|
||||||
|
}
|
||||||
|
|
||||||
if (closeZipFile) closeZipFile();
|
if (closeZipFile) closeZipFile();
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue