add precondition for mount/unmount in commands response
This commit is contained in:
parent
209e4e940e
commit
2937a55582
@ -234,6 +234,12 @@ command_available([[maybe_unused]] const Partition &partition,
|
|||||||
return neighbor_commands_available(partition.instance);
|
return neighbor_commands_available(partition.instance);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_DATABASE
|
||||||
|
if (StringIsEqual(cmd->cmd, "mount") ||
|
||||||
|
StringIsEqual(cmd->cmd, "unmount"))
|
||||||
|
return mount_commands_available(partition.instance);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (StringIsEqual(cmd->cmd, "save") ||
|
if (StringIsEqual(cmd->cmd, "save") ||
|
||||||
StringIsEqual(cmd->cmd, "rm") ||
|
StringIsEqual(cmd->cmd, "rm") ||
|
||||||
StringIsEqual(cmd->cmd, "rename") ||
|
StringIsEqual(cmd->cmd, "rename") ||
|
||||||
|
@ -275,3 +275,15 @@ handle_unmount(Client &client, Request args, Response &r)
|
|||||||
|
|
||||||
return CommandResult::OK;
|
return CommandResult::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
mount_commands_available(Instance &instance) noexcept
|
||||||
|
{
|
||||||
|
#ifdef ENABLE_DATABASE
|
||||||
|
if (auto *db = dynamic_cast<SimpleDatabase *>(instance.GetDatabase())) {
|
||||||
|
return db->HasCache();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include "CommandResult.hxx"
|
#include "CommandResult.hxx"
|
||||||
|
|
||||||
|
struct Instance;
|
||||||
class Client;
|
class Client;
|
||||||
class Storage;
|
class Storage;
|
||||||
class Request;
|
class Request;
|
||||||
@ -42,4 +43,8 @@ handle_mount(Client &client, Request request, Response &response);
|
|||||||
CommandResult
|
CommandResult
|
||||||
handle_unmount(Client &client, Request request, Response &response);
|
handle_unmount(Client &client, Request request, Response &response);
|
||||||
|
|
||||||
|
[[gnu::pure]]
|
||||||
|
bool
|
||||||
|
mount_commands_available(Instance &instance) noexcept;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -86,6 +86,10 @@ public:
|
|||||||
return *root;
|
return *root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HasCache() const noexcept {
|
||||||
|
return !cache_path.IsNull();
|
||||||
|
}
|
||||||
|
|
||||||
void Save();
|
void Save();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user