|
6 | 6 | //! |
7 | 7 | //! Requirements: |
8 | 8 | //! * Existing extra files added by users should be kept |
| 9 | +//! * Directories may not exist: it can be run without any existing files or against an existing database |
| 10 | +//! * Should avoid blocking the main thread: watched directories can be quite large on mainnet and |
| 11 | +//! library users may be downloading archives in a multithreaded context |
9 | 12 | //! * Found offenders should be reported |
| 13 | +//! * Users should be able to easily distinct folders or directories from reported offenders |
| 14 | +//! * Reported list should be ordered so running twice with the same offenders yield the same message |
| 15 | +//! * Should take in particularities: |
| 16 | +//! * networks: immutables file numbers start at 1 on most network, but 0 on devnet |
| 17 | +//! * ancillaries' inclusion: it adds another immutables trio to the downloaded files |
10 | 18 | //! |
11 | 19 | use std::collections::HashSet; |
12 | 20 | use std::ffi::OsString; |
@@ -56,13 +64,12 @@ impl UnexpectedDownloadedFileVerifier { |
56 | 64 | } |
57 | 65 | } |
58 | 66 |
|
59 | | - /// Compute the expected state of the folder after download finish |
| 67 | + /// Compute the expected state of the folder after download completed |
60 | 68 | pub async fn compute_expected_state_after_download( |
61 | 69 | &self, |
62 | 70 | ) -> StdResult<ExpectedFilesAfterDownload> { |
63 | 71 | let immutable_files_dir = self.target_cardano_db_dir.join(IMMUTABLE_DIR); |
64 | 72 | let immutable_files_range_to_expect = self.immutable_files_range_to_expect.clone(); |
65 | | - // target databases can be quite large, avoid blocking the main thread |
66 | 73 | let expected_files = |
67 | 74 | tokio::task::spawn_blocking(move || -> StdResult<HashSet<OsString>> { |
68 | 75 | let mut files: HashSet<OsString> = if immutable_files_dir.exists() { |
@@ -132,7 +139,6 @@ impl ExpectedFilesAfterDownload { |
132 | 139 | }) |
133 | 140 | .collect() |
134 | 141 | } else { |
135 | | - // The immutable dir can be missing if the download was interrupted |
136 | 142 | Vec::new() |
137 | 143 | }; |
138 | 144 | let mut removed_entries = Vec::new(); |
@@ -172,7 +178,6 @@ impl ExpectedFilesAfterDownload { |
172 | 178 | if removed_entries.is_empty() { |
173 | 179 | Ok(None) |
174 | 180 | } else { |
175 | | - // Sort removed entries to ensure consistent output when reporting to users |
176 | 181 | removed_entries.sort(); |
177 | 182 |
|
178 | 183 | slog::warn!( |
|
0 commit comments