alfredbaudisch / pardall_markdown

Reactive publishing framework, filesystem-based with support for Markdown, nested hierarchies, and instant content rebuilding. Written in Elixir.
Apache License 2.0
115 stars 7 forks source link

FileWatcher should create root_path when it doesn't exist; RepositoryWatcher should make the initial pull only after recheck_pending_remote_events_interval elapses #52

Closed alfredbaudisch closed 2 years ago

alfredbaudisch commented 2 years ago

Problem

This sometimes creates rush conditions between RepositoryWatcher and FileWatcher, which leads to FileWatcher getting stuck, for example #51.

This is mainly because when using content from an external repository, the content root_path folder may still not exist in the server when the application is started, because the folder is created by RepositoryProviders.Git.

This only happens when remote_repository_url is set.

Proposed Solution

  1. Upon application start, before FileWatcher starts watching for changes, it should check whether root_path exists, if not, creates it.
  2. Validate configuration upon application start: crash if recheck_pending_remote_events_interval < recheck_pending_file_events_interval.
    • Add the validation as the first thing into PardallMarkdown.Application.start/2 or try something like Vapor (although Vapor doesn't support custom validators).
    • Docs should mention that recheck_pending_remote_events_interval must be greater than recheck_pending_file_events_interval.
  3. RepositoryWatcher should start watching for changes after the first recheck_pending_remote_events_interval elapses.
    • Currently it starts pooling for changes right away, and uses recheck_pending_remote_events_interval only for subsequent pulls.