Pi66

merodi
A markdown-based static site generator.
git clone https://git.pi66.xyz/merodi

← back to log

fix: clear_all_hashes signature, full_reload, GlobalStore accessors, compile_file order, remove dead should_skip_file

author: pi66
date: 2026-07-21 10:29
hash: 25b2dda071038ab618cef3151120523fa448ad85

Diffstat:

M

src/api.py
17 +++++++++++++++-

M

src/build.py
11 +---------

M

src/hash.py
3 ++-

M

src/watcher.py
32 ++++++++++++++----------------
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
diff --git a/src/api.py b/src/api.py
index 4309730..ea920cd 100644
--- a/src/api.py
+++ b/src/api.py
@@ -2,7 +2,22 @@

 class GlobalStore:
     def __init__(self):
-        self.data = {}
+        self._data = {}
+
+    def get(self, key, default=None):
+        return self._data.get(key, default)
+
+    def set(self, key, value):
+        self._data[key] = value
+
+    def has(self, key):
+        return key in self._data
+
+    def delete(self, key):
+        self._data.pop(key, None)
+
+    def clear(self):
+        self._data.clear()

 class API:
     def __init__(self):
diff --git a/src/build.py b/src/build.py
index ded6aa4..9dacc87 100644
--- a/src/build.py
+++ b/src/build.py
@@ -174,19 +174,9 @@ def read_md_content(md_file):
     md_content = hook_call("on_page_read", md_file, md_content) or md_content
     return md_content

-def should_skip_file(config, md_file, force=False):
-    if config and not force:
-        hash_result = handle_hash_sync(config, md_file)
-        if hash_result is None and path.exists(md_file.rsplit(".", 1)[0] + ".html"):
-            hook_call("on_page_skip", md_file)
-            info(f"Skipping {GRAY(md_file)}...")
-            return True
-    return False
-
 @expose("compile_file")
 def compile_file(md_file, html_dest, config=None, plugins=None, force: bool = False):
     hook_call("on_compile_start", md_file)
-    md_content = read_md_content(md_file)
     if config and not force:
         hash_result = handle_hash_sync(config, md_file)
         if hash_result is None and path.exists(html_dest):
@@ -194,6 +184,7 @@ def compile_file(md_file, html_dest, config=None, plugins=None, force: bool = Fa
             info(f"Skipping {GRAY(md_file)}...")
             return None

+    md_content = read_md_content(md_file)
     info(f"Building {GRAY(md_file)}...")
     result = compile_page(md_content, html_dest, config, plugins)
     hook_call("on_page_built", md_file, html_dest)
diff --git a/src/hash.py b/src/hash.py
index 40465b3..6d1094f 100644
--- a/src/hash.py
+++ b/src/hash.py
@@ -23,9 +23,10 @@ def write_hash_file(config):
     global HASH_FILE_CONTENT
     write_file(config.cache.hash, json.dumps(HASH_FILE_CONTENT, indent=2))

-def clear_all_hashes():
+def clear_all_hashes(config):
     global HASH_FILE_CONTENT
     HASH_FILE_CONTENT = {}
+    write_hash_file(config)

 def clear_file_hash(md_path):
     global HASH_FILE_CONTENT
diff --git a/src/watcher.py b/src/watcher.py
index 8d9a62b..140d87d 100644
--- a/src/watcher.py
+++ b/src/watcher.py
@@ -6,7 +6,7 @@ import time
 from src.hooks import hook_call

 from .config import find_project_from_path, load_config
-from .build import compile_file, load_plugins
+from .build import compile_file, load_plugins, build_all
 from .log import warn
 from .errors import fatal

@@ -17,7 +17,7 @@ def is_template_or_plugin(file_path, config):
     return (file_path.startswith(config.tree.templates) or
             file_path.startswith(config.tree.plugins))

-def single_file_reload(changed_path, config, force=None):
+def single_file_reload(changed_path, config):
     global current_page
     try:
         if changed_path.endswith(".md"):
@@ -28,7 +28,7 @@ def single_file_reload(changed_path, config, force=None):
         md_relpath = path.relpath(current_page, config.tree.markdown)
         html = path.splitext(md_relpath)[0] + ".html"
         dest = path.join(config.tree.dest, html)
-        compile_status = compile_file(current_page, dest, config, _plugins, force=force)
+        compile_status = compile_file(current_page, dest, config, _plugins)
         if compile_status is None:
             return None
         return html
@@ -36,12 +36,11 @@ def single_file_reload(changed_path, config, force=None):
         hook_call("on_reload_error", e)
         warn(str(e))

-def full_reload(config, force=None):
-    global current_page, _plugins
+def full_reload(config, plugins):
+    global current_page
     try:
-        _plugins = load_plugins(config)
-        for md_file in __import__('os').walk(config.tree.markdown):
-            pass
+        build_all(config, plugins)
+        return current_page
     except Exception as e:
         hook_call("on_reload_error", e)
         warn(str(e))
@@ -63,14 +62,13 @@ def watch_files(config, reload_func=None):
                         reload_func("")
                     return

-                force = False
-                if reload_path.startswith(config.tree.templates):
-                    force = True
-                if reload_path.startswith(config.tree.plugins):
-                    _plugins = load_plugins(config)
-                    hook_call("on_plugin_changed", reload_path)
-                    if reload_func:
-                        reload_func("")
+                if is_template_or_plugin(reload_path, config):
+                    if reload_path.startswith(config.tree.plugins):
+                        _plugins = load_plugins(config)
+                        hook_call("on_plugin_changed", reload_path)
+                    file = full_reload(config, _plugins)
+                    if reload_func and file:
+                        reload_func(file)
                     return

                 now = time.time()
@@ -79,7 +77,7 @@ def watch_files(config, reload_func=None):
                     return
                 last_reload[reload_path] = now
                 hook_call("on_file_changed", reload_path, config)
-                file = single_file_reload(reload_path, config, force=force)
+                file = single_file_reload(reload_path, config)
                 if reload_func and file:
                     reload_func(file)
             except Exception as e: