Refined the commands

This commit is contained in:
2024-02-18 14:38:31 +01:00
parent 3e08d6a438
commit 4d859efdac
3 changed files with 151 additions and 80 deletions

View File

@@ -384,9 +384,19 @@ Status RemoveEntryDisk(const char* entry_identifier) {
}
Status ResetEntryDisk(const char* entry_identifier, const char* backing_identifier) {
// Check if the disk exists
// Check that the entry exists
bool exists;
Status status = DoesEntryDiskExist(entry_identifier, &exists);
Status status = DoesEntryExist(entry_identifier, &exists);
if (status != SUCCESS)
return status;
if (!exists) {
Log(LOG_LEVEL_ERROR, "The entry '%s' does not exist.", entry_identifier);
return FAILURE;
}
// Check if the disk exists
status = DoesEntryDiskExist(entry_identifier, &exists);
if (status != SUCCESS)
return status;
@@ -438,7 +448,7 @@ Status ResetEntryDisk(const char* entry_identifier, const char* backing_identifi
}
Status TrimEntryDisk(const char* entry_identifier) {
// Check if the disk exists
// Check if the entry exists
bool exists;
Status status = DoesEntryDiskExist(entry_identifier, &exists);
if (status != SUCCESS)
@@ -449,6 +459,16 @@ Status TrimEntryDisk(const char* entry_identifier) {
return FAILURE;
}
// Check if the disk exists
status = DoesEntryDiskExist(entry_identifier, &exists);
if (status != SUCCESS)
return status;
if (!exists) {
Log(LOG_LEVEL_ERROR, "The disk for the entry '%s' does not exist.", entry_identifier);
return FAILURE;
}
// Get the disk path
char* entry_disk_path = NULL;
status = GetEntryDiskPath(entry_identifier, &entry_disk_path);
@@ -461,3 +481,4 @@ Status TrimEntryDisk(const char* entry_identifier) {
return status;
}