@@ -41,6 +41,10 @@ class FileWatcher:
4141 automatic re-indexing when changes are detected.
4242 """
4343
44+ # Class constants for configuration limits
45+ MIN_DEBOUNCE_SECONDS = 1
46+ MIN_CHECK_INTERVAL = 5
47+
4448 def __init__ (
4549 self ,
4650 logger : Optional [logging .Logger ] = None ,
@@ -58,8 +62,8 @@ def __init__(
5862 check_interval: Seconds between directory scans (default: 10)
5963 """
6064 self .enabled = enabled
61- self .debounce_seconds = max (1 , debounce_seconds )
62- self .check_interval = max (5 , check_interval )
65+ self .debounce_seconds = max (self . MIN_DEBOUNCE_SECONDS , debounce_seconds )
66+ self .check_interval = max (self . MIN_CHECK_INTERVAL , check_interval )
6367
6468 # Set up logger
6569 if logger :
@@ -285,13 +289,15 @@ def _check_project(self, project_id: str, project_info: Dict) -> None:
285289
286290 def _scan_directory (self , directory : str ) -> Dict [str , str ]:
287291 """
288- Scan a directory and return a dictionary of file paths to modification times.
292+ Scan a directory and return a dictionary of file paths to file signatures.
293+
294+ Uses both modification time and file size for better change detection.
289295
290296 Args:
291297 directory: Directory path to scan
292298
293299 Returns:
294- Dictionary mapping relative file paths to modification time hashes
300+ Dictionary mapping relative file paths to signature (mtime:size)
295301 """
296302 file_hashes = {}
297303
@@ -309,10 +315,12 @@ def _scan_directory(self, directory: str) -> Dict[str, str]:
309315 filepath = os .path .join (root , filename )
310316
311317 try :
312- # Use modification time as a simple hash
313- mtime = os .path .getmtime (filepath )
318+ # Use both modification time and file size as signature
319+ stat = os .stat (filepath )
320+ mtime = stat .st_mtime
321+ size = stat .st_size
314322 relative_path = os .path .relpath (filepath , directory )
315- file_hashes [relative_path ] = str ( mtime )
323+ file_hashes [relative_path ] = f" { mtime } : { size } "
316324 except (OSError , ValueError ):
317325 # Skip files we can't access
318326 continue
0 commit comments