Prevent deletion of backup files during restore process (#1249)
This commit is contained in:
@@ -176,6 +176,7 @@ The git repositories are hosted at the following sites:
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
* Prevent deletion of backup files during restore process. (#1249)
|
||||||
* Fixed Device Management-Backup and Restore-B Backup_Failure_Timeout
|
* Fixed Device Management-Backup and Restore-B Backup_Failure_Timeout
|
||||||
to count down and abort at BACKUP_FAILURE or RESTORE_FAILURE states,
|
to count down and abort at BACKUP_FAILURE or RESTORE_FAILURE states,
|
||||||
successful STARTBACKUP to end in PERFORMING_A_BACKUP state,
|
successful STARTBACKUP to end in PERFORMING_A_BACKUP state,
|
||||||
|
|||||||
@@ -3852,12 +3852,20 @@ void Device_End_Restore(void)
|
|||||||
#if defined BACNET_BACKUP_RESTORE
|
#if defined BACNET_BACKUP_RESTORE
|
||||||
BACNET_DATE_TIME bdateTime = { 0 };
|
BACNET_DATE_TIME bdateTime = { 0 };
|
||||||
BACNET_CREATE_OBJECT_DATA create_data = { 0 };
|
BACNET_CREATE_OBJECT_DATA create_data = { 0 };
|
||||||
|
struct object_functions *device_functions = NULL;
|
||||||
|
delete_object_function file_function = NULL;
|
||||||
uint8_t apdu[MAX_APDU] = { 0 };
|
uint8_t apdu[MAX_APDU] = { 0 };
|
||||||
int32_t apdu_len = 0, offset = 0, file_size = 0;
|
int32_t apdu_len = 0, offset = 0, file_size = 0;
|
||||||
int decoded_len = 0;
|
int decoded_len = 0;
|
||||||
|
|
||||||
datetime_local(&bdateTime.date, &bdateTime.time, NULL, NULL);
|
datetime_local(&bdateTime.date, &bdateTime.time, NULL, NULL);
|
||||||
bacapp_timestamp_datetime_set(&Last_Restore_Time, &bdateTime);
|
bacapp_timestamp_datetime_set(&Last_Restore_Time, &bdateTime);
|
||||||
|
/* avoid deleting our backup file - don't delete files */
|
||||||
|
device_functions = Device_Object_Functions_Find(OBJECT_FILE);
|
||||||
|
if (device_functions) {
|
||||||
|
file_function = device_functions->Object_Delete;
|
||||||
|
device_functions->Object_Delete = NULL;
|
||||||
|
}
|
||||||
/* delete all existing objects before restore */
|
/* delete all existing objects before restore */
|
||||||
Device_Delete_Objects();
|
Device_Delete_Objects();
|
||||||
/* create objects from the backup file */
|
/* create objects from the backup file */
|
||||||
@@ -3892,6 +3900,10 @@ void Device_End_Restore(void)
|
|||||||
if (Backup_State != BACKUP_STATE_RESTORE_FAILURE) {
|
if (Backup_State != BACKUP_STATE_RESTORE_FAILURE) {
|
||||||
Backup_State = BACKUP_STATE_IDLE;
|
Backup_State = BACKUP_STATE_IDLE;
|
||||||
}
|
}
|
||||||
|
if (device_functions) {
|
||||||
|
/* restore the delete-object for file objects */
|
||||||
|
device_functions->Object_Delete = file_function;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -135,7 +135,7 @@
|
|||||||
defined(CONFIG_BACNET_BASIC_OBJECT_FILE) || \
|
defined(CONFIG_BACNET_BASIC_OBJECT_FILE) || \
|
||||||
defined(CONFIG_BACNET_BASIC_OBJECT_STRUCTURED_VIEW) || \
|
defined(CONFIG_BACNET_BASIC_OBJECT_STRUCTURED_VIEW) || \
|
||||||
defined(CONFIG_BACNET_BASIC_OBJECT_BITSTRING_VALUE) || \
|
defined(CONFIG_BACNET_BASIC_OBJECT_BITSTRING_VALUE) || \
|
||||||
defined(CONFIG_BACNET_BASIC_OBJECT_OCTET_STRING_VALUE) || \
|
defined(CONFIG_BACNET_BASIC_OBJECT_OCTET_STRING_VALUE) || \
|
||||||
defined(CONFIG_BACNET_BASIC_OBJECT_TIME_VALUE) || \
|
defined(CONFIG_BACNET_BASIC_OBJECT_TIME_VALUE) || \
|
||||||
defined(CONFIG_BACNET_BASIC_OBJECT_TIMER) || \
|
defined(CONFIG_BACNET_BASIC_OBJECT_TIMER) || \
|
||||||
defined(CONFIG_BACNET_BASIC_OBJECT_LOOP) || \
|
defined(CONFIG_BACNET_BASIC_OBJECT_LOOP) || \
|
||||||
@@ -3714,12 +3714,20 @@ void Device_End_Restore(void)
|
|||||||
#if defined BACNET_BACKUP_RESTORE
|
#if defined BACNET_BACKUP_RESTORE
|
||||||
BACNET_DATE_TIME bdateTime = { 0 };
|
BACNET_DATE_TIME bdateTime = { 0 };
|
||||||
BACNET_CREATE_OBJECT_DATA create_data = { 0 };
|
BACNET_CREATE_OBJECT_DATA create_data = { 0 };
|
||||||
|
struct object_functions *device_functions = NULL;
|
||||||
|
delete_object_function file_function = NULL;
|
||||||
uint8_t apdu[MAX_APDU] = { 0 };
|
uint8_t apdu[MAX_APDU] = { 0 };
|
||||||
int32_t apdu_len = 0, offset = 0, file_size = 0;
|
int32_t apdu_len = 0, offset = 0, file_size = 0;
|
||||||
int decoded_len = 0;
|
int decoded_len = 0;
|
||||||
|
|
||||||
datetime_local(&bdateTime.date, &bdateTime.time, NULL, NULL);
|
datetime_local(&bdateTime.date, &bdateTime.time, NULL, NULL);
|
||||||
bacapp_timestamp_datetime_set(&Last_Restore_Time, &bdateTime);
|
bacapp_timestamp_datetime_set(&Last_Restore_Time, &bdateTime);
|
||||||
|
/* avoid deleting our backup file - don't delete files */
|
||||||
|
device_functions = Device_Object_Functions_Find(OBJECT_FILE);
|
||||||
|
if (device_functions) {
|
||||||
|
file_function = device_functions->Object_Delete;
|
||||||
|
device_functions->Object_Delete = NULL;
|
||||||
|
}
|
||||||
/* delete all existing objects before restore */
|
/* delete all existing objects before restore */
|
||||||
Device_Delete_Objects();
|
Device_Delete_Objects();
|
||||||
/* create objects from the backup file */
|
/* create objects from the backup file */
|
||||||
@@ -3754,6 +3762,10 @@ void Device_End_Restore(void)
|
|||||||
if (Backup_State != BACKUP_STATE_RESTORE_FAILURE) {
|
if (Backup_State != BACKUP_STATE_RESTORE_FAILURE) {
|
||||||
Backup_State = BACKUP_STATE_IDLE;
|
Backup_State = BACKUP_STATE_IDLE;
|
||||||
}
|
}
|
||||||
|
if (device_functions) {
|
||||||
|
/* restore the delete-object for file objects */
|
||||||
|
device_functions->Object_Delete = file_function;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user