feat: Implement auto-update for All Daily Notes.md

This commit is contained in:
Tanner Collin (aider) 2025-06-13 18:43:41 +00:00
parent cfc11495e6
commit f6ba56651e

29
main.py
View File

@ -29,7 +29,34 @@ def collect_daily_notes():
return []
def main():
collect_daily_notes()
daily_notes_list = collect_daily_notes()
if not daily_notes_list:
logging.info("No daily notes found or an error occurred. Skipping update of 'All Daily Notes.md'.")
return
all_daily_notes_path = os.path.join(NOTES_DIR, 'All Daily Notes.md')
new_content = "\n\n".join(daily_notes_list)
try:
with open(all_daily_notes_path, 'r') as f:
existing_content = f.read()
except FileNotFoundError:
existing_content = ""
logging.info(f"File not found: {all_daily_notes_path}. A new file will be created.")
except OSError as e:
logging.error(f"Error reading file {all_daily_notes_path}: {e}")
return
if new_content.strip() != existing_content.strip():
try:
with open(all_daily_notes_path, 'w') as f:
f.write(new_content)
logging.info(f"Updated {all_daily_notes_path}")
except OSError as e:
logging.error(f"Error writing to file {all_daily_notes_path}: {e}")
else:
logging.info(f"No changes detected for {all_daily_notes_path}. File not updated.")
if __name__ == '__main__':
main()