mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-14 10:13:05 +02:00
Storage interface methods no longer declare the driver as const.
This works for the Posix driver but is bad for more dynamic drivers (e.g. S3) that need write access to the driver object.
This commit is contained in:
parent
12b3be1d8e
commit
2150a26424
@ -98,6 +98,10 @@
|
||||
<p>Construct <code>Wait</code> object in milliseconds instead of fractional seconds.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<p><code>Storage</code> interface methods no longer declare the driver as const.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<p>Add <code>memContextCallbackClear()</code> to prevent double <code>free()</code> calls.</p>
|
||||
</release-item>
|
||||
|
@ -19,7 +19,7 @@ Object type
|
||||
struct StorageDriverPosixFileRead
|
||||
{
|
||||
MemContext *memContext;
|
||||
const StorageDriverPosix *storage;
|
||||
StorageDriverPosix *storage;
|
||||
StorageFileRead *interface;
|
||||
IoRead *io;
|
||||
String *name;
|
||||
@ -33,7 +33,7 @@ struct StorageDriverPosixFileRead
|
||||
Create a new file
|
||||
***********************************************************************************************************************************/
|
||||
StorageDriverPosixFileRead *
|
||||
storageDriverPosixFileReadNew(const StorageDriverPosix *storage, const String *name, bool ignoreMissing)
|
||||
storageDriverPosixFileReadNew(StorageDriverPosix *storage, const String *name, bool ignoreMissing)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STRING, name);
|
||||
|
@ -17,7 +17,7 @@ typedef struct StorageDriverPosixFileRead StorageDriverPosixFileRead;
|
||||
/***********************************************************************************************************************************
|
||||
Constructor
|
||||
***********************************************************************************************************************************/
|
||||
StorageDriverPosixFileRead *storageDriverPosixFileReadNew(const StorageDriverPosix *storage, const String *name, bool ignoreMissing);
|
||||
StorageDriverPosixFileRead *storageDriverPosixFileReadNew(StorageDriverPosix *storage, const String *name, bool ignoreMissing);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
|
@ -20,7 +20,7 @@ Object type
|
||||
struct StorageDriverPosixFileWrite
|
||||
{
|
||||
MemContext *memContext;
|
||||
const StorageDriverPosix *storage;
|
||||
StorageDriverPosix *storage;
|
||||
StorageFileWrite *interface;
|
||||
IoWrite *io;
|
||||
|
||||
@ -50,7 +50,7 @@ Create a new file
|
||||
***********************************************************************************************************************************/
|
||||
StorageDriverPosixFileWrite *
|
||||
storageDriverPosixFileWriteNew(
|
||||
const StorageDriverPosix *storage, const String *name, mode_t modeFile, mode_t modePath, bool createPath, bool syncFile,
|
||||
StorageDriverPosix *storage, const String *name, mode_t modeFile, mode_t modePath, bool createPath, bool syncFile,
|
||||
bool syncPath, bool atomic)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
|
@ -19,7 +19,7 @@ typedef struct StorageDriverPosixFileWrite StorageDriverPosixFileWrite;
|
||||
Constructor
|
||||
***********************************************************************************************************************************/
|
||||
StorageDriverPosixFileWrite *storageDriverPosixFileWriteNew(
|
||||
const StorageDriverPosix *storage, const String *name, mode_t modeFile, mode_t modePath, bool createPath, bool syncFile,
|
||||
StorageDriverPosix *storage, const String *name, mode_t modeFile, mode_t modePath, bool createPath, bool syncFile,
|
||||
bool syncPath, bool atomic);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
|
@ -74,7 +74,7 @@ storageDriverPosixNew(
|
||||
Does a file/path exist?
|
||||
***********************************************************************************************************************************/
|
||||
bool
|
||||
storageDriverPosixExists(const StorageDriverPosix *this, const String *path)
|
||||
storageDriverPosixExists(StorageDriverPosix *this, const String *path)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_DRIVER_POSIX, this);
|
||||
@ -106,7 +106,7 @@ storageDriverPosixExists(const StorageDriverPosix *this, const String *path)
|
||||
File/path info
|
||||
***********************************************************************************************************************************/
|
||||
StorageInfo
|
||||
storageDriverPosixInfo(const StorageDriverPosix *this, const String *file, bool ignoreMissing)
|
||||
storageDriverPosixInfo(StorageDriverPosix *this, const String *file, bool ignoreMissing)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_DRIVER_POSIX, this);
|
||||
@ -154,7 +154,7 @@ storageDriverPosixInfo(const StorageDriverPosix *this, const String *file, bool
|
||||
Get a list of files from a directory
|
||||
***********************************************************************************************************************************/
|
||||
StringList *
|
||||
storageDriverPosixList(const StorageDriverPosix *this, const String *path, bool errorOnMissing, const String *expression)
|
||||
storageDriverPosixList(StorageDriverPosix *this, const String *path, bool errorOnMissing, const String *expression)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_DRIVER_POSIX, this);
|
||||
@ -226,7 +226,7 @@ storageDriverPosixList(const StorageDriverPosix *this, const String *path, bool
|
||||
Move a path/file
|
||||
***********************************************************************************************************************************/
|
||||
bool
|
||||
storageDriverPosixMove(const StorageDriverPosix *this, StorageDriverPosixFileRead *source, StorageDriverPosixFileWrite *destination)
|
||||
storageDriverPosixMove(StorageDriverPosix *this, StorageDriverPosixFileRead *source, StorageDriverPosixFileWrite *destination)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_DRIVER_POSIX, this);
|
||||
@ -294,7 +294,7 @@ storageDriverPosixMove(const StorageDriverPosix *this, StorageDriverPosixFileRea
|
||||
New file read object
|
||||
***********************************************************************************************************************************/
|
||||
StorageFileRead *
|
||||
storageDriverPosixNewRead(const StorageDriverPosix *this, const String *file, bool ignoreMissing)
|
||||
storageDriverPosixNewRead(StorageDriverPosix *this, const String *file, bool ignoreMissing)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_DRIVER_POSIX, this);
|
||||
@ -305,7 +305,8 @@ storageDriverPosixNewRead(const StorageDriverPosix *this, const String *file, bo
|
||||
FUNCTION_DEBUG_ASSERT(file != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
FUNCTION_DEBUG_RESULT(STORAGE_FILE_READ, storageDriverPosixFileReadInterface(storageDriverPosixFileReadNew(this, file, ignoreMissing)));
|
||||
FUNCTION_DEBUG_RESULT(
|
||||
STORAGE_FILE_READ, storageDriverPosixFileReadInterface(storageDriverPosixFileReadNew(this, file, ignoreMissing)));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -313,18 +314,18 @@ New file write object
|
||||
***********************************************************************************************************************************/
|
||||
StorageFileWrite *
|
||||
storageDriverPosixNewWrite(
|
||||
const StorageDriverPosix *this, const String *file, mode_t modeFile, mode_t modePath, bool createPath, bool syncFile,
|
||||
bool syncPath, bool atomic)
|
||||
StorageDriverPosix *this, const String *file, mode_t modeFile, mode_t modePath, bool createPath, bool syncFile, bool syncPath,
|
||||
bool atomic)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_DRIVER_POSIX, this);
|
||||
FUNCTION_TEST_PARAM(STRING, file);
|
||||
FUNCTION_TEST_PARAM(MODE, modeFile);
|
||||
FUNCTION_TEST_PARAM(MODE, modePath);
|
||||
FUNCTION_TEST_PARAM(BOOL, createPath);
|
||||
FUNCTION_TEST_PARAM(BOOL, syncFile);
|
||||
FUNCTION_TEST_PARAM(BOOL, syncPath);
|
||||
FUNCTION_TEST_PARAM(BOOL, atomic);
|
||||
FUNCTION_DEBUG_PARAM(STRING, file);
|
||||
FUNCTION_DEBUG_PARAM(MODE, modeFile);
|
||||
FUNCTION_DEBUG_PARAM(MODE, modePath);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, createPath);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, syncFile);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, syncPath);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, atomic);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_DEBUG_ASSERT(file != NULL);
|
||||
@ -340,8 +341,7 @@ storageDriverPosixNewWrite(
|
||||
Create a path
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
storageDriverPosixPathCreate(
|
||||
const StorageDriverPosix *this, const String *path, bool errorOnExists, bool noParentCreate, mode_t mode)
|
||||
storageDriverPosixPathCreate(StorageDriverPosix *this, const String *path, bool errorOnExists, bool noParentCreate, mode_t mode)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_DRIVER_POSIX, this);
|
||||
@ -375,7 +375,7 @@ storageDriverPosixPathCreate(
|
||||
Remove a path
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
storageDriverPosixPathRemove(const StorageDriverPosix *this, const String *path, bool errorOnMissing, bool recurse)
|
||||
storageDriverPosixPathRemove(StorageDriverPosix *this, const String *path, bool errorOnMissing, bool recurse)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_DRIVER_POSIX, this);
|
||||
@ -433,7 +433,7 @@ storageDriverPosixPathRemove(const StorageDriverPosix *this, const String *path,
|
||||
Sync a path
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
storageDriverPosixPathSync(const StorageDriverPosix *this, const String *path, bool ignoreMissing)
|
||||
storageDriverPosixPathSync(StorageDriverPosix *this, const String *path, bool ignoreMissing)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_DRIVER_POSIX, this);
|
||||
@ -464,7 +464,7 @@ storageDriverPosixPathSync(const StorageDriverPosix *this, const String *path, b
|
||||
Remove a file
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
storageDriverPosixRemove(const StorageDriverPosix *this, const String *file, bool errorOnMissing)
|
||||
storageDriverPosixRemove(StorageDriverPosix *this, const String *file, bool errorOnMissing)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_DRIVER_POSIX, this);
|
||||
@ -511,9 +511,7 @@ storageDriverPosixFree(StorageDriverPosix *this)
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
if (this != NULL)
|
||||
{
|
||||
memContextFree(this->memContext);
|
||||
}
|
||||
|
||||
FUNCTION_DEBUG_RESULT_VOID();
|
||||
}
|
||||
|
@ -32,21 +32,19 @@ StorageDriverPosix *storageDriverPosixNew(
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
***********************************************************************************************************************************/
|
||||
bool storageDriverPosixExists(const StorageDriverPosix *this, const String *path);
|
||||
StorageInfo storageDriverPosixInfo(const StorageDriverPosix *this, const String *file, bool ignoreMissing);
|
||||
StringList *storageDriverPosixList(
|
||||
const StorageDriverPosix *this, const String *path, bool errorOnMissing, const String *expression);
|
||||
bool storageDriverPosixMove(
|
||||
const StorageDriverPosix *this, StorageDriverPosixFileRead *source, StorageDriverPosixFileWrite *destination);
|
||||
StorageFileRead *storageDriverPosixNewRead(const StorageDriverPosix *this, const String *file, bool ignoreMissing);
|
||||
bool storageDriverPosixExists(StorageDriverPosix *this, const String *path);
|
||||
StorageInfo storageDriverPosixInfo(StorageDriverPosix *this, const String *file, bool ignoreMissing);
|
||||
StringList *storageDriverPosixList(StorageDriverPosix *this, const String *path, bool errorOnMissing, const String *expression);
|
||||
bool storageDriverPosixMove(StorageDriverPosix *this, StorageDriverPosixFileRead *source, StorageDriverPosixFileWrite *destination);
|
||||
StorageFileRead *storageDriverPosixNewRead(StorageDriverPosix *this, const String *file, bool ignoreMissing);
|
||||
StorageFileWrite *storageDriverPosixNewWrite(
|
||||
const StorageDriverPosix *this, const String *file, mode_t modeFile, mode_t modePath, bool createPath, bool syncFile,
|
||||
bool syncPath, bool atomic);
|
||||
StorageDriverPosix *this, const String *file, mode_t modeFile, mode_t modePath, bool createPath, bool syncFile, bool syncPath,
|
||||
bool atomic);
|
||||
void storageDriverPosixPathCreate(
|
||||
const StorageDriverPosix *this, const String *path, bool errorOnExists, bool noParentCreate, mode_t mode);
|
||||
void storageDriverPosixPathRemove(const StorageDriverPosix *this, const String *path, bool errorOnMissing, bool recurse);
|
||||
void storageDriverPosixPathSync(const StorageDriverPosix *this, const String *path, bool ignoreMissing);
|
||||
void storageDriverPosixRemove(const StorageDriverPosix *this, const String *file, bool errorOnMissing);
|
||||
StorageDriverPosix *this, const String *path, bool errorOnExists, bool noParentCreate, mode_t mode);
|
||||
void storageDriverPosixPathRemove(StorageDriverPosix *this, const String *path, bool errorOnMissing, bool recurse);
|
||||
void storageDriverPosixPathSync(StorageDriverPosix *this, const String *path, bool ignoreMissing);
|
||||
void storageDriverPosixRemove(StorageDriverPosix *this, const String *file, bool errorOnMissing);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Getters
|
||||
|
@ -18,7 +18,7 @@ Object type
|
||||
struct Storage
|
||||
{
|
||||
MemContext *memContext;
|
||||
const void *driver;
|
||||
void *driver;
|
||||
StorageInterface interface;
|
||||
const String *type;
|
||||
|
||||
@ -35,7 +35,7 @@ New storage object
|
||||
Storage *
|
||||
storageNew(
|
||||
const String *type, const String *path, mode_t modeFile, mode_t modePath, bool write,
|
||||
StoragePathExpressionCallback pathExpressionFunction, const void *driver, StorageInterface interface)
|
||||
StoragePathExpressionCallback pathExpressionFunction, void *driver, StorageInterface interface)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STRING, type);
|
||||
|
@ -20,19 +20,18 @@ typedef String *(*StoragePathExpressionCallback)(const String *expression, const
|
||||
/***********************************************************************************************************************************
|
||||
Constructor
|
||||
***********************************************************************************************************************************/
|
||||
typedef bool (*StorageInterfaceExists)(const void *driver, const String *path);
|
||||
typedef StorageInfo (*StorageInterfaceInfo)(const void *driver, const String *file, bool ignoreMissing);
|
||||
typedef StringList *(*StorageInterfaceList)(const void *driver, const String *path, bool errorOnMissing, const String *expression);
|
||||
typedef bool (*StorageInterfaceMove)(const void *driver, void *source, void *destination);
|
||||
typedef StorageFileRead *(*StorageInterfaceNewRead)(const void *driver, const String *file, bool ignoreMissing);
|
||||
typedef bool (*StorageInterfaceExists)(void *driver, const String *path);
|
||||
typedef StorageInfo (*StorageInterfaceInfo)(void *driver, const String *file, bool ignoreMissing);
|
||||
typedef StringList *(*StorageInterfaceList)(void *driver, const String *path, bool errorOnMissing, const String *expression);
|
||||
typedef bool (*StorageInterfaceMove)(void *driver, void *source, void *destination);
|
||||
typedef StorageFileRead *(*StorageInterfaceNewRead)(void *driver, const String *file, bool ignoreMissing);
|
||||
typedef StorageFileWrite *(*StorageInterfaceNewWrite)(
|
||||
const void *driver, const String *file, mode_t modeFile, mode_t modePath, bool createPath, bool syncFile, bool syncPath,
|
||||
bool atomic);
|
||||
void *driver, const String *file, mode_t modeFile, mode_t modePath, bool createPath, bool syncFile, bool syncPath, bool atomic);
|
||||
typedef void (*StorageInterfacePathCreate)(
|
||||
const void *driver, const String *path, bool errorOnExists, bool noParentCreate, mode_t mode);
|
||||
typedef void (*StorageInterfacePathRemove)(const void *driver, const String *path, bool errorOnMissing, bool recurse);
|
||||
typedef void (*StorageInterfacePathSync)(const void *driver, const String *path, bool ignoreMissing);
|
||||
typedef void (*StorageInterfaceRemove)(const void *driver, const String *file, bool errorOnMissing);
|
||||
void *driver, const String *path, bool errorOnExists, bool noParentCreate, mode_t mode);
|
||||
typedef void (*StorageInterfacePathRemove)(void *driver, const String *path, bool errorOnMissing, bool recurse);
|
||||
typedef void (*StorageInterfacePathSync)(void *driver, const String *path, bool ignoreMissing);
|
||||
typedef void (*StorageInterfaceRemove)(void *driver, const String *file, bool errorOnMissing);
|
||||
|
||||
typedef struct StorageInterface
|
||||
{
|
||||
@ -48,12 +47,12 @@ typedef struct StorageInterface
|
||||
StorageInterfaceRemove remove;
|
||||
} StorageInterface;
|
||||
|
||||
#define storageNewP(type, path, modeFile, modePath, write, pathExpressionFunction, driver, ...) \
|
||||
#define storageNewP(type, path, modeFile, modePath, write, pathExpressionFunction, driver, ...) \
|
||||
storageNew(type, path, modeFile, modePath, write, pathExpressionFunction, driver, (StorageInterface){__VA_ARGS__})
|
||||
|
||||
Storage *storageNew(
|
||||
const String *type, const String *path, mode_t modeFile, mode_t modePath, bool write,
|
||||
StoragePathExpressionCallback pathExpressionFunction, const void *driver, StorageInterface interface);
|
||||
StoragePathExpressionCallback pathExpressionFunction, void *driver, StorageInterface interface);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Macros for function logging
|
||||
|
Loading…
Reference in New Issue
Block a user