From 575c277ff47169189c4302e8ddccafd659b42c80 Mon Sep 17 00:00:00 2001 From: Masahiko AMANO Date: Tue, 27 Dec 2022 23:50:23 +0300 Subject: [PATCH] perf(cli): check if database is full before launching add menu --- cli/cli.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cli/cli.c b/cli/cli.c index bc6eb93..585f64a 100644 --- a/cli/cli.c +++ b/cli/cli.c @@ -107,6 +107,10 @@ int menu_view_tanzaku() { // Sasa add menu handler int menu_add_sasa() { + if (tanabata.sasahyou.size == -1 && tanabata.sasahyou.hole_cnt == 0) { + fprintf(stderr, ERROR("Failed to add file to database: sasahyou is full\n")); + return 1; + } char path[4096]; printf(HIGHLIGHT("Enter file path: ")); fgets(path, 4096, stdin); @@ -126,6 +130,10 @@ int menu_add_sasa() { // Tanzaku add menu handler int menu_add_tanzaku() { + if (tanabata.sappyou.size == -1 && tanabata.sappyou.hole_cnt == 0) { + fprintf(stderr, ERROR("Failed to add tanzaku: sappyou is full\n")); + return 1; + } char name[4096]; char description[4096]; printf(HIGHLIGHT("Enter tanzaku name: ")); @@ -149,6 +157,10 @@ int menu_add_tanzaku() { // Kazari add menu handler int menu_add_kazari() { + if (tanabata.shoppyou.size == -1 && tanabata.shoppyou.hole_cnt == 0) { + fprintf(stderr, ERROR("Failed to add kazari: shoppyou is full\n")); + return 1; + } char input[16]; printf(HIGHLIGHT("Enter sasa ID: ")); fgets(input, 16, stdin);