1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-01 00:25:06 +02:00

Require storage when calling pgControlFromFile().

Previously storageLocal() was being used internally but loading pg_control from remote storage is often required.

Also, storagePg() is more appropriate than storageLocal() for all current usage.

Contributed by Cynthia Shang.
This commit is contained in:
Cynthia Shang
2019-08-21 11:29:30 -04:00
committed by David Steele
parent 286a106ae4
commit 6a09d9294d
8 changed files with 31 additions and 27 deletions

View File

@ -311,12 +311,14 @@ pgControlFromBuffer(const Buffer *controlFile)
Get info from pg_control
***********************************************************************************************************************************/
PgControl
pgControlFromFile(const String *pgPath)
pgControlFromFile(const Storage *storage, const String *pgPath)
{
FUNCTION_LOG_BEGIN(logLevelDebug);
FUNCTION_LOG_PARAM(STORAGE, storage);
FUNCTION_LOG_PARAM(STRING, pgPath);
FUNCTION_LOG_END();
ASSERT(storage != NULL);
ASSERT(pgPath != NULL);
PgControl result = {0};
@ -325,7 +327,7 @@ pgControlFromFile(const String *pgPath)
{
// Read control file
Buffer *controlFile = storageGetP(
storageNewReadNP(storageLocal(), strNewFmt("%s/" PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, strPtr(pgPath))),
storageNewReadNP(storage, strNewFmt("%s/" PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, strPtr(pgPath))),
.exactSize = PG_CONTROL_DATA_SIZE);
result = pgControlFromBuffer(controlFile);