FileHistory
Object Hierarchy:
Description:
public class FileHistory : Object
Represents a file change history entry. Handles backup creation and database storage for file changes.
This class tracks what happened to each file during command execution and edit file actions. It is organized around files (what users
understand), not operations (implementation details).
Key Purpose
This table is primarily for user review, approval, and restoration of changes: - User thinks in terms of files: "What happened to file
X?" rather than "What operations occurred?" - Listing file changes for user review before applying them - Backing up files so they can be
compared (diff) - Approving/rejecting file changes with ability to restore if rejected - Restoring files if changes are rejected -
Reviewing what changed and when for each file
Ignored Files
Files with `is_ignored = true` are filtered out and not tracked in the file_history table. Only non-ignored files are recorded in the
history for user review and approval.
Content:
Properties:
- public int agent_id { get; set; }
Agent identifier (0 for now, may be used later to track which
agent/tool made the change).
- public string alias_target { get; set; }
Target path if file was previously an alias (symlink target). Empty
string "" if file was not an alias. Stored for restoration purposes.
- public string backup_path { get; set; }
Path where the old version will be saved (empty string "" for new
files). This is the path where FileHistory class will save the backup of the original file. Used for restoration if change is
rejected.
- public string base_type { get; set; }
The file type before it was changed (matches filebase base_type
standard). Type identifiers: "f" = File, "d" = Folder/Directory, "fa" = FileAlias (alias/symlink).
- public string change_type { get; set; }
Change type: "added", "modified", or "deleted". User-friendly: "file X
was deleted", "file Y was modified", "file Z was added".
- public int64 filebase_id { get; set; }
Reference to filebase record (0 for new files or deleted files).
Deleted files are removed from filebase.
- public int64 id { get; set; }
Database ID.
- public string moved_from { get; set; }
Source path (for rename operations when file was added - file was
moved from here). For renames: change_type="added", path = new path, moved_from = original path. Empty string "" for non-rename
operations (regular add, delete, modify).
- public string moved_to { get; set; }
Destination path (for rename operations when file was deleted - file
was moved to here). For renames: change_type="deleted", path = original path, moved_to = destination path. Empty string "" for non-
rename operations (regular delete, add, modify).
- public string path { get; set; }
The file path (primary identifier - what user cares about).
- public int status { get; set; }
User approval state (0 = pending, 1 = approved, -1 = rejected). - 0 =
pending (not yet reviewed) - 1 = approved (user approved the change) - -1 = rejected (user rejected the change)
- public int64 timestamp { get; set; }
When the change occurred (when file was removed or changed). For
overlay/command execution updates, all timestamps for the same command/run/edit should be the same (based on when the command/run/edit
started, NOT when the record was created).
Static methods:
- public static async void cleanup_old_backups (Database db, int max_deleted_days = 30)
Cleanup old backup files from the backup directory and database
records.
- public static void init_db (Database db)
Initialize file_history table in database.
- public static Query<FileHistory> query (Database db)
Create a query object for file_history table.
Creation methods:
Methods:
Inherited Members:
All known members inherited from class GLib.Object
- @get
- @new
- @ref
- @set
- add_toggle_ref
- add_weak_pointer
- bind_property
- connect
- constructed
- disconnect
- dispose
- dup_data
- dup_qdata
- force_floating
- freeze_notify
- get_class
- get_data
- get_property
- get_qdata
- get_type
- getv
- interface_find_property
- interface_install_property
- interface_list_properties
- is_floating
- new_valist
- new_with_properties
- newv
- notify
- notify_property
- ref_count
- ref_sink
- remove_toggle_ref
- remove_weak_pointer
- replace_data
- replace_qdata
- set_data
- set_data_full
- set_property
- set_qdata
- set_qdata_full
- set_valist
- setv
- steal_data
- steal_qdata
- thaw_notify
- unref
- watch_closure
- weak_ref
- weak_unref