Class: Archaeo::DownloadState
- Inherits:
-
Object
- Object
- Archaeo::DownloadState
- Defined in:
- lib/archaeo/download_state.rb
Overview
Tracks download progress for resume support.
Persists completed snapshot timestamps to a state file within the output directory, allowing interrupted downloads to resume without re-fetching already downloaded snapshots.
Constant Summary collapse
- STATE_FILE =
".archaeo-state"
Instance Attribute Summary collapse
-
#output_dir ⇒ Object
readonly
Returns the value of attribute output_dir.
Instance Method Summary collapse
- #clear ⇒ Object
- #completed?(timestamp) ⇒ Boolean
-
#initialize(output_dir) ⇒ DownloadState
constructor
A new instance of DownloadState.
- #mark_completed(timestamp) ⇒ Object
Constructor Details
#initialize(output_dir) ⇒ DownloadState
Returns a new instance of DownloadState.
14 15 16 17 |
# File 'lib/archaeo/download_state.rb', line 14 def initialize(output_dir) @output_dir = output_dir @path = File.join(output_dir, STATE_FILE) end |
Instance Attribute Details
#output_dir ⇒ Object (readonly)
Returns the value of attribute output_dir.
12 13 14 |
# File 'lib/archaeo/download_state.rb', line 12 def output_dir @output_dir end |
Instance Method Details
#clear ⇒ Object
28 29 30 31 |
# File 'lib/archaeo/download_state.rb', line 28 def clear @timestamps = [] FileUtils.rm_f(@path) end |
#completed?(timestamp) ⇒ Boolean
19 20 21 |
# File 'lib/archaeo/download_state.rb', line 19 def completed?() .include?(.to_s) end |
#mark_completed(timestamp) ⇒ Object
23 24 25 26 |
# File 'lib/archaeo/download_state.rb', line 23 def mark_completed() << .to_s save end |