class Fontist::Indexes::IncrementalIndexUpdater
Service for performing incremental index updates Only scans changed files/directories instead of full scans
Constants
- CHANGE_DETECTION_TTL
- SNAPSHOT_TTL
Attributes
Public Class Methods
Source
# File lib/fontist/indexes/incremental_index_updater.rb, line 16 def initialize(directory_path) @directory_path = directory_path @changes = [] end
Initialize updater for a directory
Public Instance Methods
Source
# File lib/fontist/indexes/incremental_index_updater.rb, line 44 def added_files @changes.select(&:added?) end
Get list of added files
Source
# File lib/fontist/indexes/incremental_index_updater.rb, line 59 def changes? @changes.any? end
Check if any changes were detected
Source
# File lib/fontist/indexes/incremental_index_updater.rb, line 49 def modified_files @changes.select(&:modified?) end
Get list of modified files
Source
# File lib/fontist/indexes/incremental_index_updater.rb, line 54 def removed_files @changes.select(&:removed?) end
Get list of removed files
Source
# File lib/fontist/indexes/incremental_index_updater.rb, line 64 def stats { total_changes: @changes.size, added: added_files.size, modified: modified_files.size, removed: removed_files.size, } end
Get scan statistics
Source
# File lib/fontist/indexes/incremental_index_updater.rb, line 23 def update old_snapshot = load_snapshot new_snapshot = create_snapshot @changes = if old_snapshot.nil? # First scan - all files are new new_snapshot.files.map do |file| DirectoryChange.added(file[:filename], file) end else # Detect changes DirectoryChange.diff(old_snapshot, new_snapshot) end # Save new snapshot for next time save_snapshot(new_snapshot) @changes end
Perform incremental update Returns: Array of DirectoryChange objects