module
Memo::Files
Overview
File indexing support for memo CLI
Provides directory walking with ignore file support, binary file detection, and file metadata tracking for incremental updates.
Extended Modules
Defined in:
memo/files.crInstance Method Summary
-
#binary?(path : String) : Bool
Check if file is binary using libmagic
-
#binary_by_content?(path : String, sample_size : Int32 = 8192) : Bool
Fallback binary detection by checking for null bytes
-
#collect(root : String, ignore_file : String = ".gitignore") : Array(String)
Collect all text files in directory
-
#content_hash(path : String) : Bytes
Compute SHA256 hash of file content
-
#count(db : DB::Database) : Int64
Count indexed files
-
#delete(db : DB::Database, source_id : Int64) : Bool
Delete file record
-
#file_info(path : String, root : String) : FileInfo
Get file info (path, hash, mtime, size)
-
#get_by_hash(db : DB::Database, hash : Bytes) : FileRecord | Nil
Get file record by content hash
-
#get_by_path(db : DB::Database, path : String) : FileRecord | Nil
Get file record by path
-
#get_by_source(db : DB::Database, source_id : Int64) : FileRecord | Nil
Get file record by source_id
-
#list(db : DB::Database, limit : Int32 = 100, offset : Int32 = 0) : Array(FileRecord)
List all indexed files
-
#needs_update?(record : FileRecord, current_mtime : Int64) : Bool
Check if file needs re-indexing (mtime changed)
-
#store(db : DB::Database, source_id : Int64, info : FileInfo)
Store file record in database
-
#walk(root : String, ignore_file : String = ".gitignore", &block : String -> )
Walk directory and yield text files, respecting ignore patterns
Instance Method Detail
Fallback binary detection by checking for null bytes
Collect all text files in directory
Get file info (path, hash, mtime, size)
Get file record by content hash
Get file record by path
Get file record by source_id
List all indexed files
Check if file needs re-indexing (mtime changed)
Store file record in database
Walk directory and yield text files, respecting ignore patterns
Uses ignoreme for .gitignore-style filtering. Uses magic.cr to detect and skip binary files.
Options:
- root: Directory to walk
- ignore_file: Ignore file name (default ".gitignore")