Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b0e06dce2 | ||
|
|
db7bb624e4 | ||
|
|
4a8a554396 |
No files matched your search
@@ -0,0 +1,12 @@
|
||||
build-essential
|
||||
ca-certificates
|
||||
curl
|
||||
libcurl4-openssl-dev
|
||||
libdrm-dev
|
||||
libegl1-mesa-dev
|
||||
libgbm-dev
|
||||
libgles2-mesa-dev
|
||||
libsdl2-dev
|
||||
patchelf
|
||||
pkg-config
|
||||
zip
|
||||
@@ -80,6 +80,8 @@ jobs:
|
||||
name: Build Linux
|
||||
runs-on: ubuntu-latest
|
||||
needs: test
|
||||
env:
|
||||
APT_CACHE_DIR: /tmp/apt-cache
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
@@ -88,22 +90,24 @@ jobs:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Cache Linux apt packages
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ env.APT_CACHE_DIR }}
|
||||
key: linux-apt-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.github/apt/linux-packages.txt') }}
|
||||
restore-keys: |
|
||||
linux-apt-${{ runner.os }}-${{ runner.arch }}-
|
||||
|
||||
- name: Install Linux Dependencies
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mapfile -t packages < .github/apt/linux-packages.txt
|
||||
mkdir -p "$APT_CACHE_DIR/partial"
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
build-essential \
|
||||
ca-certificates \
|
||||
curl \
|
||||
libcurl4-openssl-dev \
|
||||
libdrm-dev \
|
||||
libegl1-mesa-dev \
|
||||
libgbm-dev \
|
||||
libgles2-mesa-dev \
|
||||
libsdl2-dev \
|
||||
patchelf \
|
||||
pkg-config \
|
||||
zip
|
||||
sudo apt-get \
|
||||
-o Dir::Cache::archives="$APT_CACHE_DIR" \
|
||||
install -y "${packages[@]}"
|
||||
sudo chown -R "$USER:$USER" "$APT_CACHE_DIR"
|
||||
|
||||
- name: Install AppImage Tools
|
||||
run: |
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
# Changelog
|
||||
## [1.3.6] - 2026-06-18
|
||||
### Fixed
|
||||
- Fixed Tickmate `.db` imports so zero-based months map correctly and long habit histories load without dropping later dates.
|
||||
|
||||
## [1.3.5] - 2026-06-18
|
||||
### Fixed
|
||||
- Improved Android data import for `.db` backups, weekly habit rows, and import conflict handling.
|
||||
|
||||
## [1.3.4] - 2026-06-18
|
||||
### Changed
|
||||
- Reorganized WHM and Meditation into practice-owned modules for cleaner code boundaries.
|
||||
|
||||
@@ -35,8 +35,8 @@ android {
|
||||
defaultConfig {
|
||||
minSdk 19
|
||||
targetSdk 35
|
||||
versionCode 32
|
||||
versionName "1.3.4"
|
||||
versionCode 34
|
||||
versionName "1.3.6"
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -281,7 +281,8 @@ public class MainActivity extends NativeActivity {
|
||||
"application/x-zip-compressed",
|
||||
"application/vnd.sqlite3",
|
||||
"application/x-sqlite",
|
||||
"application/x-sqlite3"
|
||||
"application/x-sqlite3",
|
||||
"application/octet-stream"
|
||||
});
|
||||
startActivityForResult(intent, REQUEST_IMPORT_ZIP);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
### Fixed
|
||||
- Improved Android data import for `.db` backups, weekly habit rows, and import conflict handling.
|
||||
@@ -0,0 +1,2 @@
|
||||
### Fixed
|
||||
- Fixed Tickmate `.db` imports so zero-based months map correctly and long habit histories load without dropping later dates.
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
|
||||
#define INBE_VERSION_MAJOR 1
|
||||
#define INBE_VERSION_MINOR 3
|
||||
#define INBE_VERSION_PATCH 4
|
||||
#define INBE_VERSION_STRING "1.3.4"
|
||||
#define INBE_VERSION_PATCH 6
|
||||
#define INBE_VERSION_STRING "1.3.6"
|
||||
|
||||
#endif
|
||||
+87
-24
@@ -21,9 +21,10 @@ extern int view_width;
|
||||
extern int view_height;
|
||||
|
||||
enum {
|
||||
HABIT_WEEKLY_INITIAL_DAYS = 7,
|
||||
HABIT_WEEKLY_LOAD_DAYS = 7,
|
||||
HABIT_WEEKLY_MAX_DAYS = INBE_HABIT_MAX_DAYS
|
||||
HABIT_WEEKLY_MONTH_DAYS = 31,
|
||||
HABIT_WEEKLY_INITIAL_DAYS = HABIT_WEEKLY_MONTH_DAYS,
|
||||
HABIT_WEEKLY_LOAD_DAYS = HABIT_WEEKLY_MONTH_DAYS,
|
||||
HABIT_WEEKLY_MAX_DAYS = 36500
|
||||
};
|
||||
|
||||
/* Helper functions */
|
||||
@@ -43,7 +44,7 @@ copy_text(char *dst, size_t dst_size, const char *src)
|
||||
static int
|
||||
habit_find_day(const InbeHabit *habit, int day_index)
|
||||
{
|
||||
if(habit == NULL)
|
||||
if(habit == NULL || habit->days == NULL)
|
||||
return -1;
|
||||
for(int i = 0; i < habit->day_count; i++) {
|
||||
if(habit->days[i].day_index == day_index)
|
||||
@@ -52,6 +53,43 @@ habit_find_day(const InbeHabit *habit, int day_index)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
inbe_habit_reserve_days(InbeHabit *habit, int capacity)
|
||||
{
|
||||
InbeHabitDay *days;
|
||||
int new_capacity;
|
||||
|
||||
if(habit == NULL || capacity <= habit->day_capacity)
|
||||
return habit != NULL;
|
||||
new_capacity = habit->day_capacity > 0 ? habit->day_capacity : 16;
|
||||
while(new_capacity < capacity) {
|
||||
if(new_capacity > 1073741823 / 2)
|
||||
return 0;
|
||||
new_capacity *= 2;
|
||||
}
|
||||
days = realloc(habit->days, (size_t)new_capacity * sizeof(*days));
|
||||
if(days == NULL)
|
||||
return 0;
|
||||
memset(days + habit->day_capacity, 0,
|
||||
(size_t)(new_capacity - habit->day_capacity) * sizeof(*days));
|
||||
habit->days = days;
|
||||
habit->day_capacity = new_capacity;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
inbe_habits_free(InbeHabits *habits)
|
||||
{
|
||||
if(habits == NULL)
|
||||
return;
|
||||
for(int i = 0; i < INBE_HABIT_MAX; i++) {
|
||||
free(habits->items[i].days);
|
||||
habits->items[i].days = NULL;
|
||||
habits->items[i].day_count = 0;
|
||||
habits->items[i].day_capacity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Core habits functions from habits.c */
|
||||
int
|
||||
inbe_habits_today_index(void)
|
||||
@@ -96,7 +134,6 @@ inbe_habits_clear_days(InbeHabits *habits)
|
||||
if(habit->days[d].day_index > 0 || habit->days[d].completed)
|
||||
cleared++;
|
||||
}
|
||||
memset(habit->days, 0, sizeof(habit->days));
|
||||
habit->day_count = 0;
|
||||
}
|
||||
return cleared;
|
||||
@@ -123,6 +160,7 @@ inbe_habits_add_default_set(InbeHabits *habits)
|
||||
if(habits == NULL)
|
||||
return;
|
||||
|
||||
inbe_habits_free(habits);
|
||||
memset(habits, 0, sizeof(*habits));
|
||||
inbe_habits_add_seed(habits, "meditation", "Meditation", (Color){126, 183, 230, 255},
|
||||
habit_activity_mask_for(EXERCISE_WIM_HOF) |
|
||||
@@ -138,6 +176,7 @@ inbe_habits_delete(InbeHabits *habits, int index)
|
||||
if(habits == NULL || index < 0 || index >= habits->count)
|
||||
return;
|
||||
|
||||
free(habits->items[index].days);
|
||||
for(int i = index; i < habits->count - 1; i++)
|
||||
habits->items[i] = habits->items[i + 1];
|
||||
habits->count--;
|
||||
@@ -232,7 +271,7 @@ inbe_habit_set_day(InbeHabits *habits, int index, int day_index, int completed)
|
||||
existing_index = habit_find_day(habit, day_index);
|
||||
if(existing_index >= 0) {
|
||||
habit->days[existing_index].completed = completed != 0;
|
||||
} else if(completed && habit->day_count < INBE_HABIT_MAX_DAYS) {
|
||||
} else if(completed && inbe_habit_reserve_days(habit, habit->day_count + 1)) {
|
||||
habit->days[habit->day_count].day_index = day_index;
|
||||
habit->days[habit->day_count].completed = 1;
|
||||
habit->day_count++;
|
||||
@@ -254,7 +293,7 @@ inbe_habit_toggle_day(InbeHabits *habits, int index, int day_index)
|
||||
existing_index = habit_find_day(habit, day_index);
|
||||
if(existing_index >= 0) {
|
||||
habit->days[existing_index].completed = !habit->days[existing_index].completed;
|
||||
} else if(habit->day_count < INBE_HABIT_MAX_DAYS) {
|
||||
} else if(inbe_habit_reserve_days(habit, habit->day_count + 1)) {
|
||||
habit->days[habit->day_count].day_index = day_index;
|
||||
habit->days[habit->day_count].completed = 1;
|
||||
habit->day_count++;
|
||||
@@ -771,6 +810,26 @@ draw_habit_link_dot(int x, int y, int w, Color color)
|
||||
flint_px(3), color);
|
||||
}
|
||||
|
||||
static Color
|
||||
habit_text_color_for_background(Color background)
|
||||
{
|
||||
int luma = background.r * 299 + background.g * 587 + background.b * 114;
|
||||
|
||||
return luma >= 128000 ? BLACK : WHITE;
|
||||
}
|
||||
|
||||
static void
|
||||
habit_weekly_draw_text_line(const char *text, int x, int y, int w, int h,
|
||||
int text_size, Color color)
|
||||
{
|
||||
int font_size;
|
||||
|
||||
if(text == NULL || text[0] == '\0' || w <= 0 || h <= 0)
|
||||
return;
|
||||
font_size = flint_px(text_size);
|
||||
flint_text_draw(text, x, flint_text_y(text, y, h, font_size), font_size, color);
|
||||
}
|
||||
|
||||
static int
|
||||
habit_weekly_summary(const HabitLinkedContext *ctx, int day_index,
|
||||
char *primary, size_t primary_size,
|
||||
@@ -821,8 +880,9 @@ habit_weekly_summary_button(InbeApp *app, int x, int y, int w, int h, int comple
|
||||
int hovered;
|
||||
Color fill = completed ? theme_get_button() : flint_darken(theme_get_bg(), 10);
|
||||
Color text = disabled ? flint_darken(theme_get_text(), 35) : theme_get_text();
|
||||
int font = flint_ui_font();
|
||||
int small_font = flint_px(FLINT_TEXT_8);
|
||||
int pad = flint_px(9);
|
||||
int text_x;
|
||||
int text_w;
|
||||
const char *line1 = primary != NULL ? primary : "";
|
||||
const char *line2 = secondary != NULL ? secondary : "";
|
||||
|
||||
@@ -841,25 +901,28 @@ habit_weekly_summary_button(InbeApp *app, int x, int y, int w, int h, int comple
|
||||
|
||||
if(hovered)
|
||||
fill = theme_get_button_hover();
|
||||
if(!disabled && completed)
|
||||
text = habit_text_color_for_background(fill);
|
||||
DrawRectangle(x, y, w, h, fill);
|
||||
ui_draw_bevel(x, y, w, h, flint_lighten(fill, 36), flint_darken(fill, 42));
|
||||
|
||||
text_x = x + pad;
|
||||
text_w = w - pad * 2;
|
||||
|
||||
if(line1[0] != '\0') {
|
||||
if(line2[0] != '\0') {
|
||||
flint_text_draw_fitted_in_rect(line1,
|
||||
(Rectangle){x + flint_px(8), y + flint_px(5),
|
||||
w - flint_px(16), flint_px(18)},
|
||||
font, FLINT_TEXT_12, text);
|
||||
flint_text_draw_fitted_in_rect(line2,
|
||||
(Rectangle){x + flint_px(8), y + flint_px(24),
|
||||
w - flint_px(16), flint_px(12)},
|
||||
small_font, FLINT_TEXT_8,
|
||||
flint_darken(text, 16));
|
||||
int line1_h = flint_px(24);
|
||||
int line2_h = flint_px(16);
|
||||
int block_h = line1_h + line2_h;
|
||||
int block_y = y + (h - block_h) / 2;
|
||||
habit_weekly_draw_text_line(line1, text_x, block_y, text_w, line1_h,
|
||||
FLINT_TEXT_16, text);
|
||||
habit_weekly_draw_text_line(line2, text_x, block_y + line1_h, text_w, line2_h,
|
||||
FLINT_TEXT_8, flint_darken(text, 16));
|
||||
} else {
|
||||
flint_text_draw_fitted_in_rect(line1,
|
||||
(Rectangle){x + flint_px(8), y,
|
||||
w - flint_px(16), h},
|
||||
font, FLINT_TEXT_16, text);
|
||||
habit_weekly_draw_text_line(line1, text_x, y + flint_px(3),
|
||||
text_w, h - flint_px(6),
|
||||
FLINT_TEXT_16, text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -883,7 +946,7 @@ habit_weekly_visible_days(InbeHabits *habits)
|
||||
static int
|
||||
habit_weekly_content_height(int visible_days)
|
||||
{
|
||||
int row_h = flint_px(40);
|
||||
int row_h = flint_px(44);
|
||||
int row_gap = flint_px(6);
|
||||
int load_h = flint_px(38);
|
||||
|
||||
@@ -908,7 +971,7 @@ draw_habits_weekly_view(InbeApp *app, InbeHabit *active, int selected,
|
||||
int gap = flint_px(8);
|
||||
int button_x;
|
||||
int button_w;
|
||||
int row_h = flint_px(40);
|
||||
int row_h = flint_px(44);
|
||||
int row_gap = flint_px(6);
|
||||
int day_font = flint_px(16);
|
||||
int date_font = flint_px(FLINT_TEXT_8);
|
||||
|
||||
@@ -17,7 +17,6 @@ enum {
|
||||
INBE_HABIT_MAX = 10,
|
||||
INBE_HABIT_ID_SIZE = 32,
|
||||
INBE_HABIT_NAME_SIZE = 40,
|
||||
INBE_HABIT_MAX_DAYS = 366,
|
||||
HABIT_LINKED_ENTRY_MAX = 128,
|
||||
HABIT_LINKED_PATH_SIZE = 80
|
||||
};
|
||||
@@ -45,8 +44,9 @@ typedef struct InbeHabit {
|
||||
Color color;
|
||||
int sync_mode;
|
||||
int sync_activity;
|
||||
InbeHabitDay days[INBE_HABIT_MAX_DAYS];
|
||||
InbeHabitDay *days;
|
||||
int day_count;
|
||||
int day_capacity;
|
||||
} InbeHabit;
|
||||
|
||||
typedef struct InbeHabits {
|
||||
@@ -89,8 +89,10 @@ typedef struct HabitLinkedContext {
|
||||
|
||||
/* Core habits functions */
|
||||
void inbe_habits_init(InbeHabits *habits);
|
||||
void inbe_habits_free(InbeHabits *habits);
|
||||
void inbe_habits_save(const InbeHabits *habits);
|
||||
int inbe_habits_clear_days(InbeHabits *habits);
|
||||
int inbe_habit_reserve_days(InbeHabit *habit, int capacity);
|
||||
int inbe_habits_today_index(void);
|
||||
int inbe_habit_completed_day(const InbeHabit *habit, int day_index);
|
||||
int inbe_habit_completed_today(const InbeHabit *habit);
|
||||
|
||||
+32
-14
@@ -1045,6 +1045,7 @@ inbe_storage_habits_load(void *habits_ptr)
|
||||
|
||||
if(habits == NULL || g_storage.db == NULL)
|
||||
return 0;
|
||||
inbe_habits_free(habits);
|
||||
memset(habits, 0, sizeof(*habits));
|
||||
if(sqlite3_prepare_v2(g_storage.db,
|
||||
"SELECT id,name,color_r,color_g,color_b,sync_mode,sync_activity "
|
||||
@@ -1067,12 +1068,16 @@ inbe_storage_habits_load(void *habits_ptr)
|
||||
|
||||
for(int i = 0; i < habits->count; i++) {
|
||||
if(sqlite3_prepare_v2(g_storage.db,
|
||||
"SELECT local_date,completed FROM habit_days WHERE habit_id=?1 ORDER BY local_date LIMIT 366",
|
||||
"SELECT local_date,completed FROM habit_days WHERE habit_id=?1 ORDER BY local_date",
|
||||
-1, &stmt, NULL) != SQLITE_OK)
|
||||
continue;
|
||||
bind_text(stmt, 1, habits->items[i].id);
|
||||
while(habits->items[i].day_count < INBE_HABIT_MAX_DAYS && sqlite3_step(stmt) == SQLITE_ROW) {
|
||||
while(sqlite3_step(stmt) == SQLITE_ROW) {
|
||||
int d = habits->items[i].day_count++;
|
||||
if(!inbe_habit_reserve_days(&habits->items[i], habits->items[i].day_count)) {
|
||||
habits->items[i].day_count--;
|
||||
break;
|
||||
}
|
||||
habits->items[i].days[d].day_index = sqlite3_column_int(stmt, 0);
|
||||
habits->items[i].days[d].completed = sqlite3_column_int(stmt, 1) != 0;
|
||||
}
|
||||
@@ -1502,6 +1507,17 @@ import_tickmate_db(sqlite3 *src)
|
||||
"SELECT ticks._track_id,tracks.name,ticks.year,ticks.month,ticks.day "
|
||||
"FROM ticks JOIN tracks ON tracks._id=ticks._track_id",
|
||||
-1, &stmt, NULL) == SQLITE_OK) {
|
||||
if(sqlite3_prepare_v2(g_storage.db,
|
||||
"INSERT INTO habit_days(habit_id,local_date,completed,updated_at) "
|
||||
"VALUES(?1,?2,1,?3) "
|
||||
"ON CONFLICT(habit_id,local_date) DO UPDATE SET "
|
||||
"completed=CASE WHEN habit_days.completed!=0 THEN habit_days.completed ELSE excluded.completed END,"
|
||||
"updated_at=CASE WHEN habit_days.completed!=0 THEN habit_days.updated_at ELSE excluded.updated_at END",
|
||||
-1, &write_stmt, NULL) != SQLITE_OK) {
|
||||
sqlite3_finalize(stmt);
|
||||
stmt = NULL;
|
||||
goto finish;
|
||||
}
|
||||
while(sqlite3_step(stmt) == SQLITE_ROW) {
|
||||
char import_habit_id[64];
|
||||
char local_habit_id[INBE_STORAGE_ID_SIZE];
|
||||
@@ -1514,27 +1530,24 @@ import_tickmate_db(sqlite3 *src)
|
||||
|
||||
if(name == NULL || name[0] == '\0')
|
||||
continue;
|
||||
if(year <= 0 || month <= 0 || month > 12 || day <= 0 || day > 31)
|
||||
/* Tickmate stores Android Calendar.MONTH values: January is 0. */
|
||||
if(year <= 0 || month < 0 || month > 11 || day <= 0 || day > 31)
|
||||
continue;
|
||||
local_date = year * 10000 + month * 100 + day;
|
||||
local_date = year * 10000 + (month + 1) * 100 + day;
|
||||
snprintf(import_habit_id, sizeof(import_habit_id), "tickmate-%d", track_id);
|
||||
if(!resolve_import_habit_id(import_habit_id, name, local_habit_id,
|
||||
sizeof(local_habit_id)))
|
||||
continue;
|
||||
if(sqlite3_prepare_v2(g_storage.db,
|
||||
"INSERT OR REPLACE INTO habit_days(habit_id,local_date,completed,updated_at) "
|
||||
"VALUES(?1,?2,1,?3)",
|
||||
-1, &write_stmt, NULL) != SQLITE_OK)
|
||||
continue;
|
||||
sqlite3_reset(write_stmt);
|
||||
sqlite3_clear_bindings(write_stmt);
|
||||
bind_text(write_stmt, 1, local_habit_id);
|
||||
sqlite3_bind_int(write_stmt, 2, local_date);
|
||||
sqlite3_bind_int64(write_stmt, 3, imported_at);
|
||||
if(sqlite3_step(write_stmt) == SQLITE_DONE)
|
||||
ok = 1;
|
||||
sqlite3_finalize(write_stmt);
|
||||
write_stmt = NULL;
|
||||
}
|
||||
}
|
||||
finish:
|
||||
sqlite3_finalize(stmt);
|
||||
sqlite3_finalize(write_stmt);
|
||||
exec_sql("COMMIT");
|
||||
@@ -1563,7 +1576,9 @@ import_settings_from_source(sqlite3 *src)
|
||||
continue;
|
||||
if(sqlite3_prepare_v2(g_storage.db,
|
||||
"INSERT INTO settings(user_id,key,value,updated_at) VALUES(?1,?2,?3,?4) "
|
||||
"ON CONFLICT(user_id,key) DO UPDATE SET value=excluded.value,updated_at=excluded.updated_at",
|
||||
"ON CONFLICT(user_id,key) DO UPDATE SET "
|
||||
"value=CASE WHEN excluded.value!='' OR settings.value='' THEN excluded.value ELSE settings.value END,"
|
||||
"updated_at=CASE WHEN excluded.value!='' OR settings.value='' THEN excluded.updated_at ELSE settings.updated_at END",
|
||||
-1, &write_stmt, NULL) != SQLITE_OK)
|
||||
continue;
|
||||
bind_text(write_stmt, 1, g_storage.user_id);
|
||||
@@ -1718,8 +1733,11 @@ import_sqlite_db_file(const char *db_path, InbeStorageImportMode mode)
|
||||
while(sqlite3_step(hstmt) == SQLITE_ROW) {
|
||||
sqlite3_stmt *day_stmt = NULL;
|
||||
if(sqlite3_prepare_v2(g_storage.db,
|
||||
"INSERT OR REPLACE INTO habit_days(habit_id,local_date,completed,updated_at) "
|
||||
"VALUES(?1,?2,?3,?4)",
|
||||
"INSERT INTO habit_days(habit_id,local_date,completed,updated_at) "
|
||||
"VALUES(?1,?2,?3,?4) "
|
||||
"ON CONFLICT(habit_id,local_date) DO UPDATE SET "
|
||||
"completed=CASE WHEN habit_days.completed!=0 THEN habit_days.completed ELSE excluded.completed END,"
|
||||
"updated_at=CASE WHEN habit_days.completed!=0 THEN habit_days.updated_at ELSE excluded.updated_at END",
|
||||
-1, &day_stmt, NULL) != SQLITE_OK)
|
||||
continue;
|
||||
bind_text(day_stmt, 1, local_habit_id);
|
||||
|
||||
+159
-2
@@ -11,6 +11,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static int g_failures = 0;
|
||||
@@ -159,6 +160,32 @@ write_source_database(const char *root)
|
||||
inbe_storage_close();
|
||||
}
|
||||
|
||||
static void
|
||||
insert_raw_habit_day(const char *root, const char *habit_id, int local_date, int completed)
|
||||
{
|
||||
char db_path[512];
|
||||
sqlite3 *db = NULL;
|
||||
sqlite3_stmt *stmt = NULL;
|
||||
|
||||
make_path(db_path, sizeof(db_path), root, "inbe.db");
|
||||
check_true("open raw habit day db", sqlite3_open(db_path, &db) == SQLITE_OK);
|
||||
if(db == NULL)
|
||||
return;
|
||||
if(sqlite3_prepare_v2(db,
|
||||
"INSERT OR REPLACE INTO habit_days(habit_id,local_date,completed,updated_at) "
|
||||
"VALUES(?1,?2,?3,0)",
|
||||
-1, &stmt, NULL) == SQLITE_OK) {
|
||||
sqlite3_bind_text(stmt, 1, habit_id, -1, SQLITE_TRANSIENT);
|
||||
sqlite3_bind_int(stmt, 2, local_date);
|
||||
sqlite3_bind_int(stmt, 3, completed ? 1 : 0);
|
||||
check_true("insert raw habit day", sqlite3_step(stmt) == SQLITE_DONE);
|
||||
} else {
|
||||
check_true("prepare raw habit day", 0);
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
sqlite3_close(db);
|
||||
}
|
||||
|
||||
static void
|
||||
metadata_history_callback(const char *id, int year, int month, int day,
|
||||
int hour, int minute, int second,
|
||||
@@ -338,6 +365,55 @@ test_habit_name_merge_import(void)
|
||||
remove_tree(dest);
|
||||
}
|
||||
|
||||
static void
|
||||
test_import_conflict_prefers_data_over_empty(void)
|
||||
{
|
||||
char source[512], dest[512], zip_path[512];
|
||||
InbeHabits habits;
|
||||
InbeHabit *habit;
|
||||
|
||||
make_clean_root(source, sizeof(source), "conflict-source");
|
||||
make_clean_root(dest, sizeof(dest), "conflict-dest");
|
||||
make_path(zip_path, sizeof(zip_path), source, "conflict-export.zip");
|
||||
|
||||
check_true("init conflict source", inbe_storage_init(source));
|
||||
memset(&habits, 0, sizeof(habits));
|
||||
check_int("add conflict source habit",
|
||||
inbe_habits_add_custom(&habits, "Meditation",
|
||||
(Color){224, 124, 104, 255},
|
||||
INBE_HABIT_SYNC_NONE, 0),
|
||||
0);
|
||||
inbe_storage_set_setting_text("language", "");
|
||||
inbe_storage_close();
|
||||
insert_raw_habit_day(source, "habit-1", 20260618, 0);
|
||||
check_true("reopen conflict source", inbe_storage_init(source));
|
||||
check_true("conflict source export", inbe_storage_export_zip(zip_path));
|
||||
inbe_storage_close();
|
||||
|
||||
check_true("init conflict dest", inbe_storage_init(dest));
|
||||
memset(&habits, 0, sizeof(habits));
|
||||
check_int("add conflict dest habit",
|
||||
inbe_habits_add_custom(&habits, "Meditation",
|
||||
(Color){126, 183, 230, 255},
|
||||
INBE_HABIT_SYNC_NONE, 0),
|
||||
0);
|
||||
inbe_habit_set_day(&habits, 0, 20260618, 1);
|
||||
inbe_storage_set_setting_text("language", "en");
|
||||
check_true("conflict import",
|
||||
inbe_storage_import_zip_ex(zip_path, INBE_STORAGE_IMPORT_DATA_AND_SETTINGS));
|
||||
memset(&habits, 0, sizeof(habits));
|
||||
check_true("conflict habits load", inbe_storage_habits_load(&habits));
|
||||
habit = find_habit_ci(&habits, "Meditation");
|
||||
check_true("conflict keeps completed day",
|
||||
habit != NULL && inbe_habit_completed_day(habit, 20260618));
|
||||
check_str("conflict keeps non-empty setting",
|
||||
inbe_storage_get_setting_text("language"), "en");
|
||||
inbe_storage_close();
|
||||
|
||||
remove_tree(source);
|
||||
remove_tree(dest);
|
||||
}
|
||||
|
||||
static void
|
||||
write_multi_habit_source_database(const char *root, const char *zip_path)
|
||||
{
|
||||
@@ -533,6 +609,7 @@ static void
|
||||
write_tickmate_database(const char *path)
|
||||
{
|
||||
sqlite3 *db = NULL;
|
||||
sqlite3_stmt *stmt = NULL;
|
||||
char *error = NULL;
|
||||
|
||||
check_true("open tickmate db", sqlite3_open(path, &db) == SQLITE_OK);
|
||||
@@ -550,12 +627,51 @@ write_tickmate_database(const char *path)
|
||||
"INSERT INTO tracks(_id,name,description,icon,enabled,color,\"order\") "
|
||||
"VALUES(1,'Meditation','Silenced my mind','',1,8925,0);"
|
||||
"INSERT INTO ticks(_track_id,year,month,day,hour,minute,second,has_time_info) "
|
||||
"VALUES(1,2026,6,13,0,0,0,0);",
|
||||
"VALUES(1,2026,0,1,0,0,0,0),"
|
||||
"(1,2026,1,2,0,0,0,0),"
|
||||
"(1,2026,2,3,0,0,0,0),"
|
||||
"(1,2026,3,4,0,0,0,0),"
|
||||
"(1,2026,4,5,0,0,0,0),"
|
||||
"(1,2026,5,6,0,0,0,0),"
|
||||
"(1,2026,6,7,0,0,0,0),"
|
||||
"(1,2026,7,8,0,0,0,0),"
|
||||
"(1,2026,8,9,0,0,0,0),"
|
||||
"(1,2026,9,10,0,0,0,0),"
|
||||
"(1,2026,10,11,0,0,0,0),"
|
||||
"(1,2026,11,12,0,0,0,0);",
|
||||
NULL, NULL, &error) == SQLITE_OK);
|
||||
if(error != NULL) {
|
||||
fprintf(stderr, "tickmate setup SQL error: %s\n", error);
|
||||
sqlite3_free(error);
|
||||
}
|
||||
check_true("prepare large tickmate insert",
|
||||
sqlite3_prepare_v2(db,
|
||||
"INSERT INTO ticks(_track_id,year,month,day,hour,minute,second,has_time_info) "
|
||||
"VALUES(1,?1,?2,?3,0,0,0,0)",
|
||||
-1, &stmt, NULL) == SQLITE_OK);
|
||||
if(stmt != NULL) {
|
||||
struct tm day;
|
||||
|
||||
check_true("begin large tickmate insert", sqlite3_exec(db, "BEGIN", NULL, NULL, NULL) == SQLITE_OK);
|
||||
memset(&day, 0, sizeof(day));
|
||||
day.tm_year = 2025 - 1900;
|
||||
day.tm_mon = 0;
|
||||
day.tm_mday = 1;
|
||||
day.tm_hour = 12;
|
||||
mktime(&day);
|
||||
for(int i = 0; i < 12000; i++) {
|
||||
sqlite3_reset(stmt);
|
||||
sqlite3_clear_bindings(stmt);
|
||||
sqlite3_bind_int(stmt, 1, day.tm_year + 1900);
|
||||
sqlite3_bind_int(stmt, 2, day.tm_mon);
|
||||
sqlite3_bind_int(stmt, 3, day.tm_mday);
|
||||
check_true("large tickmate insert row", sqlite3_step(stmt) == SQLITE_DONE);
|
||||
day.tm_mday++;
|
||||
mktime(&day);
|
||||
}
|
||||
check_true("commit large tickmate insert", sqlite3_exec(db, "COMMIT", NULL, NULL, NULL) == SQLITE_OK);
|
||||
sqlite3_finalize(stmt);
|
||||
}
|
||||
sqlite3_close(db);
|
||||
}
|
||||
|
||||
@@ -575,7 +691,20 @@ test_tickmate_db_import(void)
|
||||
memset(&habits, 0, sizeof(habits));
|
||||
check_true("tickmate habits load", inbe_storage_habits_load(&habits));
|
||||
check_int("tickmate habit count", habits.count, 1);
|
||||
check_true("tickmate habit day", inbe_habit_completed_day(&habits.items[0], 20260613));
|
||||
check_true("tickmate january day", inbe_habit_completed_day(&habits.items[0], 20260101));
|
||||
check_true("tickmate february day", inbe_habit_completed_day(&habits.items[0], 20260202));
|
||||
check_true("tickmate march day", inbe_habit_completed_day(&habits.items[0], 20260303));
|
||||
check_true("tickmate april day", inbe_habit_completed_day(&habits.items[0], 20260404));
|
||||
check_true("tickmate may day", inbe_habit_completed_day(&habits.items[0], 20260505));
|
||||
check_true("tickmate june day", inbe_habit_completed_day(&habits.items[0], 20260606));
|
||||
check_true("tickmate july day", inbe_habit_completed_day(&habits.items[0], 20260707));
|
||||
check_true("tickmate august day", inbe_habit_completed_day(&habits.items[0], 20260808));
|
||||
check_true("tickmate september day", inbe_habit_completed_day(&habits.items[0], 20260909));
|
||||
check_true("tickmate october day", inbe_habit_completed_day(&habits.items[0], 20261010));
|
||||
check_true("tickmate november day", inbe_habit_completed_day(&habits.items[0], 20261111));
|
||||
check_true("tickmate december day", inbe_habit_completed_day(&habits.items[0], 20261212));
|
||||
check_true("tickmate loads thousands of days",
|
||||
inbe_habit_completed_day(&habits.items[0], 20571108));
|
||||
check_true("tickmate habit name", strcmp(habits.items[0].name, "Meditation") == 0);
|
||||
inbe_storage_close();
|
||||
|
||||
@@ -583,16 +712,44 @@ test_tickmate_db_import(void)
|
||||
remove_tree(dest);
|
||||
}
|
||||
|
||||
static void
|
||||
test_external_tickmate_db_import(void)
|
||||
{
|
||||
const char *db_path = getenv("INBE_TICKMATE_IMPORT_FIXTURE");
|
||||
char dest[512];
|
||||
InbeStorageImportInfo info;
|
||||
InbeHabits habits;
|
||||
|
||||
if(db_path == NULL || db_path[0] == '\0')
|
||||
return;
|
||||
|
||||
make_clean_root(dest, sizeof(dest), "external-tickmate-dest");
|
||||
check_true("init external tickmate import dest", inbe_storage_init(dest));
|
||||
memset(&info, 0, sizeof(info));
|
||||
check_true("inspect external tickmate db", inbe_storage_inspect_import(db_path, &info));
|
||||
check_true("external tickmate db valid", info.valid);
|
||||
check_true("external tickmate db has habits", info.has_habits);
|
||||
check_true("external tickmate db import", inbe_storage_import_zip(db_path));
|
||||
memset(&habits, 0, sizeof(habits));
|
||||
check_true("external tickmate habits load", inbe_storage_habits_load(&habits));
|
||||
check_true("external tickmate habit count", habits.count > 0);
|
||||
inbe_storage_close();
|
||||
|
||||
remove_tree(dest);
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
test_raw_db_import();
|
||||
test_zip_db_import();
|
||||
test_habit_name_merge_import();
|
||||
test_import_conflict_prefers_data_over_empty();
|
||||
test_import_modes_preserve_habits_and_settings_choice();
|
||||
test_legacy_zip_import();
|
||||
test_legacy_file_startup_migration();
|
||||
test_tickmate_db_import();
|
||||
test_external_tickmate_db_import();
|
||||
test_session_metadata();
|
||||
|
||||
if(g_failures != 0) {
|
||||
|
||||
+4
-4
@@ -3,8 +3,8 @@
|
||||
IDI_APP_ICON ICON "inbe.ico"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,3,4,0
|
||||
PRODUCTVERSION 1,3,4,0
|
||||
FILEVERSION 1,3,6,0
|
||||
PRODUCTVERSION 1,3,6,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@@ -21,11 +21,11 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "CompanyName", "waozi"
|
||||
VALUE "FileDescription", "Inner Breeze"
|
||||
VALUE "FileVersion", "1.3.4"
|
||||
VALUE "FileVersion", "1.3.6"
|
||||
VALUE "InternalName", "inbe"
|
||||
VALUE "OriginalFilename", "inbe-windows-x86_64.exe"
|
||||
VALUE "ProductName", "Inner Breeze"
|
||||
VALUE "ProductVersion", "1.3.4"
|
||||
VALUE "ProductVersion", "1.3.6"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
||||
Reference in new issue
Block a user