mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-05 07:15:39 +02:00
[216195] [dstore] Saving empty file fails
This commit is contained in:
parent
bc27d20ae0
commit
96af532009
1 changed files with 22 additions and 51 deletions
|
@ -37,6 +37,7 @@
|
||||||
* David McKnight (IBM) - [216252] MessageFormat.format -> NLS.bind
|
* David McKnight (IBM) - [216252] MessageFormat.format -> NLS.bind
|
||||||
* David McKnight (IBM) - [216252] use SimpleSystemMessage instead of getMessage()
|
* David McKnight (IBM) - [216252] use SimpleSystemMessage instead of getMessage()
|
||||||
* David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared
|
* David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared
|
||||||
|
* Radoslav Gerganov (ProSyst) - [216195] [dstore] Saving empty file fails
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.services.dstore.files;
|
package org.eclipse.rse.internal.services.dstore.files;
|
||||||
|
@ -264,7 +265,13 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
String byteStreamHandlerId = getByteStreamHandlerId();
|
||||||
|
String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile;
|
||||||
|
|
||||||
|
// create an empty file on the host and append data to it later
|
||||||
|
// this handles the case of uploading empty files as well
|
||||||
|
getDataStore().replaceFile(remotePath, new byte[] {}, 0, isBinary, byteStreamHandlerId);
|
||||||
|
|
||||||
// DataElement uploadLog = findUploadLog();
|
// DataElement uploadLog = findUploadLog();
|
||||||
findUploadLog();
|
findUploadLog();
|
||||||
// listener = new FileTransferStatusListener(remotePath, shell, monitor, getConnectorService(), ds, uploadLog);
|
// listener = new FileTransferStatusListener(remotePath, shell, monitor, getConnectorService(), ds, uploadLog);
|
||||||
|
@ -275,7 +282,6 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
||||||
// read in the file
|
// read in the file
|
||||||
bufInputStream = new BufferedInputStream(inputStream, buffer_size);
|
bufInputStream = new BufferedInputStream(inputStream, buffer_size);
|
||||||
|
|
||||||
boolean first = true;
|
|
||||||
byte[] buffer = new byte[buffer_size];
|
byte[] buffer = new byte[buffer_size];
|
||||||
byte[] convBytes;
|
byte[] convBytes;
|
||||||
int numToRead = 0;
|
int numToRead = 0;
|
||||||
|
@ -311,9 +317,6 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
||||||
|
|
||||||
totalSent += bytesRead;
|
totalSent += bytesRead;
|
||||||
|
|
||||||
String byteStreamHandlerId = getByteStreamHandlerId();
|
|
||||||
String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile;
|
|
||||||
|
|
||||||
if (!isBinary && hostEncoding != null)
|
if (!isBinary && hostEncoding != null)
|
||||||
{
|
{
|
||||||
String tempStr = new String(buffer, 0, bytesRead);
|
String tempStr = new String(buffer, 0, bytesRead);
|
||||||
|
@ -350,27 +353,13 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
||||||
|
|
||||||
convBytes = tempStr.getBytes(hostEncoding);
|
convBytes = tempStr.getBytes(hostEncoding);
|
||||||
|
|
||||||
if (first)
|
// append subsequent segments
|
||||||
{ // send first set of bytes
|
getDataStore().replaceAppendFile(remotePath, convBytes, convBytes.length, true, byteStreamHandlerId);
|
||||||
first = false;
|
|
||||||
getDataStore().replaceFile(remotePath, convBytes, convBytes.length, true, byteStreamHandlerId);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // append subsequent segments
|
|
||||||
getDataStore().replaceAppendFile(remotePath, convBytes, convBytes.length, true, byteStreamHandlerId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else // binary
|
else // binary
|
||||||
{
|
{
|
||||||
if (first)
|
// append subsequent segments
|
||||||
{ // send first set of bytes
|
getDataStore().replaceAppendFile(remotePath, buffer, bytesRead, true, byteStreamHandlerId);
|
||||||
first = false;
|
|
||||||
getDataStore().replaceFile(remotePath, buffer, bytesRead, true, byteStreamHandlerId);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // append subsequent segments
|
|
||||||
getDataStore().replaceAppendFile(remotePath, buffer, bytesRead, true, byteStreamHandlerId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -459,12 +448,12 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// if the file is empty, create new empty file on host
|
String byteStreamHandlerId = getByteStreamHandlerId();
|
||||||
if (totalBytes == 0)
|
String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile;
|
||||||
{
|
|
||||||
IHostFile created = createFile(remoteParent, remoteFile, monitor);
|
// create an empty file and append data to it later
|
||||||
return created.exists();
|
// this handles the case of uploading empty files as well
|
||||||
}
|
getDataStore().replaceFile(remotePath, new byte[] {}, 0, isBinary, byteStreamHandlerId);
|
||||||
|
|
||||||
if (monitor != null)
|
if (monitor != null)
|
||||||
{
|
{
|
||||||
|
@ -484,7 +473,6 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
||||||
inputStream = new FileInputStream(file);
|
inputStream = new FileInputStream(file);
|
||||||
bufInputStream = new BufferedInputStream(inputStream, buffer_size);
|
bufInputStream = new BufferedInputStream(inputStream, buffer_size);
|
||||||
|
|
||||||
boolean first = true;
|
|
||||||
byte[] buffer = new byte[buffer_size];
|
byte[] buffer = new byte[buffer_size];
|
||||||
byte[] convBytes;
|
byte[] convBytes;
|
||||||
int numToRead = 0;
|
int numToRead = 0;
|
||||||
|
@ -520,9 +508,6 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
||||||
|
|
||||||
totalSent += bytesRead;
|
totalSent += bytesRead;
|
||||||
|
|
||||||
String byteStreamHandlerId = getByteStreamHandlerId();
|
|
||||||
String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile;
|
|
||||||
|
|
||||||
if (!isBinary && srcEncoding != null && hostEncoding != null)
|
if (!isBinary && srcEncoding != null && hostEncoding != null)
|
||||||
{
|
{
|
||||||
String tempStr = new String(buffer, 0, bytesRead, srcEncoding);
|
String tempStr = new String(buffer, 0, bytesRead, srcEncoding);
|
||||||
|
@ -559,27 +544,13 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
||||||
|
|
||||||
convBytes = codePageConverter.convertClientStringToRemoteBytes(tempStr, hostEncoding, this);
|
convBytes = codePageConverter.convertClientStringToRemoteBytes(tempStr, hostEncoding, this);
|
||||||
|
|
||||||
if (first)
|
// append subsequent segments
|
||||||
{ // send first set of bytes
|
getDataStore().replaceAppendFile(remotePath, convBytes, convBytes.length, true, byteStreamHandlerId);
|
||||||
first = false;
|
|
||||||
getDataStore().replaceFile(remotePath, convBytes, convBytes.length, true, byteStreamHandlerId);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // append subsequent segments
|
|
||||||
getDataStore().replaceAppendFile(remotePath, convBytes, convBytes.length, true, byteStreamHandlerId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else // binary
|
else // binary
|
||||||
{
|
{
|
||||||
if (first)
|
// append subsequent segments
|
||||||
{ // send first set of bytes
|
getDataStore().replaceAppendFile(remotePath, buffer, bytesRead, true, byteStreamHandlerId);
|
||||||
first = false;
|
|
||||||
getDataStore().replaceFile(remotePath, buffer, bytesRead, true, byteStreamHandlerId);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // append subsequent segments
|
|
||||||
getDataStore().replaceAppendFile(remotePath, buffer, bytesRead, true, byteStreamHandlerId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue