mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-12 10:04:14 +02:00
Move storageReadRemoteOpen() in storage/remote/read module.
This will make an upcoming important fix easier to review.
This commit is contained in:
parent
909be412f8
commit
ea162e8216
@ -43,68 +43,6 @@ Macros for function logging
|
||||
#define FUNCTION_LOG_STORAGE_READ_REMOTE_FORMAT(value, buffer, bufferSize) \
|
||||
objToLog(value, "StorageReadRemote", buffer, bufferSize)
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Open the file
|
||||
***********************************************************************************************************************************/
|
||||
static bool
|
||||
storageReadRemoteOpen(THIS_VOID)
|
||||
{
|
||||
THIS(StorageReadRemote);
|
||||
|
||||
FUNCTION_LOG_BEGIN(logLevelTrace);
|
||||
FUNCTION_LOG_PARAM(STORAGE_READ_REMOTE, this);
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
ASSERT(this != NULL);
|
||||
|
||||
bool result = false;
|
||||
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
// If the file is compressible add compression filter on the remote
|
||||
if (this->interface.compressible)
|
||||
{
|
||||
ioFilterGroupAdd(
|
||||
ioReadFilterGroup(storageReadIo(this->read)), compressFilter(compressTypeGz, (int)this->interface.compressLevel));
|
||||
}
|
||||
|
||||
ProtocolCommand *command = protocolCommandNew(PROTOCOL_COMMAND_STORAGE_OPEN_READ);
|
||||
PackWrite *const param = protocolCommandParam(command);
|
||||
|
||||
pckWriteStrP(param, this->interface.name);
|
||||
pckWriteBoolP(param, this->interface.ignoreMissing);
|
||||
pckWriteU64P(param, this->interface.offset);
|
||||
|
||||
if (this->interface.limit == NULL)
|
||||
pckWriteNullP(param);
|
||||
else
|
||||
pckWriteU64P(param, varUInt64(this->interface.limit));
|
||||
|
||||
pckWritePackP(param, ioFilterGroupParamAll(ioReadFilterGroup(storageReadIo(this->read))));
|
||||
|
||||
protocolClientCommandPut(this->client, command, false);
|
||||
|
||||
// If the file exists
|
||||
result = pckReadBoolP(protocolClientDataGet(this->client));
|
||||
|
||||
if (result)
|
||||
{
|
||||
// Clear filters since they will be run on the remote side
|
||||
ioFilterGroupClear(ioReadFilterGroup(storageReadIo(this->read)));
|
||||
|
||||
// If the file is compressible add decompression filter locally
|
||||
if (this->interface.compressible)
|
||||
ioFilterGroupAdd(ioReadFilterGroup(storageReadIo(this->read)), decompressFilter(compressTypeGz));
|
||||
}
|
||||
// Else nothing to do
|
||||
else
|
||||
protocolClientDataEndGet(this->client);
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
FUNCTION_LOG_RETURN(BOOL, result);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Read from a file
|
||||
***********************************************************************************************************************************/
|
||||
@ -209,6 +147,68 @@ storageReadRemoteEof(THIS_VOID)
|
||||
FUNCTION_TEST_RETURN(BOOL, this->eof);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Open the file
|
||||
***********************************************************************************************************************************/
|
||||
static bool
|
||||
storageReadRemoteOpen(THIS_VOID)
|
||||
{
|
||||
THIS(StorageReadRemote);
|
||||
|
||||
FUNCTION_LOG_BEGIN(logLevelTrace);
|
||||
FUNCTION_LOG_PARAM(STORAGE_READ_REMOTE, this);
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
ASSERT(this != NULL);
|
||||
|
||||
bool result = false;
|
||||
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
// If the file is compressible add compression filter on the remote
|
||||
if (this->interface.compressible)
|
||||
{
|
||||
ioFilterGroupAdd(
|
||||
ioReadFilterGroup(storageReadIo(this->read)), compressFilter(compressTypeGz, (int)this->interface.compressLevel));
|
||||
}
|
||||
|
||||
ProtocolCommand *command = protocolCommandNew(PROTOCOL_COMMAND_STORAGE_OPEN_READ);
|
||||
PackWrite *const param = protocolCommandParam(command);
|
||||
|
||||
pckWriteStrP(param, this->interface.name);
|
||||
pckWriteBoolP(param, this->interface.ignoreMissing);
|
||||
pckWriteU64P(param, this->interface.offset);
|
||||
|
||||
if (this->interface.limit == NULL)
|
||||
pckWriteNullP(param);
|
||||
else
|
||||
pckWriteU64P(param, varUInt64(this->interface.limit));
|
||||
|
||||
pckWritePackP(param, ioFilterGroupParamAll(ioReadFilterGroup(storageReadIo(this->read))));
|
||||
|
||||
protocolClientCommandPut(this->client, command, false);
|
||||
|
||||
// If the file exists
|
||||
result = pckReadBoolP(protocolClientDataGet(this->client));
|
||||
|
||||
if (result)
|
||||
{
|
||||
// Clear filters since they will be run on the remote side
|
||||
ioFilterGroupClear(ioReadFilterGroup(storageReadIo(this->read)));
|
||||
|
||||
// If the file is compressible add decompression filter locally
|
||||
if (this->interface.compressible)
|
||||
ioFilterGroupAdd(ioReadFilterGroup(storageReadIo(this->read)), decompressFilter(compressTypeGz));
|
||||
}
|
||||
// Else nothing to do
|
||||
else
|
||||
protocolClientDataEndGet(this->client);
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
FUNCTION_LOG_RETURN(BOOL, result);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
StorageRead *
|
||||
storageReadRemoteNew(
|
||||
|
Loading…
Reference in New Issue
Block a user