def timestamp(self): return datetime.now().strftime("%Y%m%d_%H%M%S")
def backup_file(self, filepath): # Create relative path to maintain folder structure rel_path = os.path.relpath(filepath, WATCH_DIR) backup_path = os.path.join(BACKUP_DIR, rel_path + f".self.timestamp().bak") os.makedirs(os.path.dirname(backup_path), exist_ok=True) windev
print(f"[Windev] Backed up: filepath → backup_path") def timestamp(self): return datetime
# Optional Git auto-commit if GIT_AUTO_COMMIT: self.git_commit(filepath) WATCH_DIR) backup_path = os.path.join(BACKUP_DIR
with open(LOG_FILE, 'w') as f: json.dump(log, f, indent=2)
def log_change(self, original, backup): log = [] if os.path.exists(LOG_FILE): with open(LOG_FILE, 'r') as f: log = json.load(f)