longleaf 0.1.0.pre.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +94 -0
  3. data/.editorconfig +13 -0
  4. data/.gitignore +4 -1
  5. data/.rubocop.yml +44 -0
  6. data/.rubocop_todo.yml +834 -0
  7. data/.yardopts +1 -0
  8. data/Gemfile +16 -1
  9. data/README.md +98 -12
  10. data/Rakefile +6 -0
  11. data/bin/setup +16 -1
  12. data/docs/aboutlongleaf.md +28 -0
  13. data/docs/extra.css +32 -0
  14. data/docs/img/change-file.png +0 -0
  15. data/docs/img/ll-example-preserved.png +0 -0
  16. data/docs/index.md +19 -0
  17. data/docs/install.md +66 -0
  18. data/docs/ll-example/config-example-relative.yml +33 -0
  19. data/docs/ll-example/files-dir/LLexample-PDF.pdf +0 -0
  20. data/docs/ll-example/files-dir/LLexample-TOCHANGE.txt +15 -0
  21. data/docs/ll-example/files-dir/LLexample-tokeep.txt +10 -0
  22. data/docs/ll-example/metadata-dir/.gitkeep +0 -0
  23. data/docs/ll-example/replica-files/.gitkeep +0 -0
  24. data/docs/ll-example/replica-metadata/.gitkeep +0 -0
  25. data/docs/quickstart.md +270 -0
  26. data/docs/rdocs/Longleaf.html +135 -0
  27. data/docs/rdocs/Longleaf/AppFields.html +178 -0
  28. data/docs/rdocs/Longleaf/ApplicationConfigDeserializer.html +631 -0
  29. data/docs/rdocs/Longleaf/ApplicationConfigManager.html +610 -0
  30. data/docs/rdocs/Longleaf/ApplicationConfigValidator.html +238 -0
  31. data/docs/rdocs/Longleaf/CLI.html +909 -0
  32. data/docs/rdocs/Longleaf/ChecksumMismatchError.html +151 -0
  33. data/docs/rdocs/Longleaf/ConfigBuilder.html +1339 -0
  34. data/docs/rdocs/Longleaf/ConfigurationError.html +143 -0
  35. data/docs/rdocs/Longleaf/ConfigurationValidator.html +227 -0
  36. data/docs/rdocs/Longleaf/DeregisterCommand.html +420 -0
  37. data/docs/rdocs/Longleaf/DeregisterEvent.html +453 -0
  38. data/docs/rdocs/Longleaf/DeregistrationError.html +151 -0
  39. data/docs/rdocs/Longleaf/DigestHelper.html +419 -0
  40. data/docs/rdocs/Longleaf/EventError.html +147 -0
  41. data/docs/rdocs/Longleaf/EventNames.html +163 -0
  42. data/docs/rdocs/Longleaf/EventStatusTracking.html +656 -0
  43. data/docs/rdocs/Longleaf/FileCheckService.html +540 -0
  44. data/docs/rdocs/Longleaf/FileHelpers.html +520 -0
  45. data/docs/rdocs/Longleaf/FileRecord.html +716 -0
  46. data/docs/rdocs/Longleaf/FileSelector.html +901 -0
  47. data/docs/rdocs/Longleaf/FixityCheckService.html +691 -0
  48. data/docs/rdocs/Longleaf/IndexManager.html +1155 -0
  49. data/docs/rdocs/Longleaf/InvalidDigestAlgorithmError.html +143 -0
  50. data/docs/rdocs/Longleaf/InvalidStoragePathError.html +143 -0
  51. data/docs/rdocs/Longleaf/Logging.html +405 -0
  52. data/docs/rdocs/Longleaf/Logging/RedirectingLogger.html +1213 -0
  53. data/docs/rdocs/Longleaf/LongleafError.html +139 -0
  54. data/docs/rdocs/Longleaf/MDFields.html +193 -0
  55. data/docs/rdocs/Longleaf/MetadataBuilder.html +787 -0
  56. data/docs/rdocs/Longleaf/MetadataDeserializer.html +537 -0
  57. data/docs/rdocs/Longleaf/MetadataError.html +143 -0
  58. data/docs/rdocs/Longleaf/MetadataPersistenceManager.html +539 -0
  59. data/docs/rdocs/Longleaf/MetadataRecord.html +1411 -0
  60. data/docs/rdocs/Longleaf/MetadataSerializer.html +786 -0
  61. data/docs/rdocs/Longleaf/PreservationServiceError.html +147 -0
  62. data/docs/rdocs/Longleaf/PreserveCommand.html +410 -0
  63. data/docs/rdocs/Longleaf/PreserveEvent.html +491 -0
  64. data/docs/rdocs/Longleaf/RegisterCommand.html +428 -0
  65. data/docs/rdocs/Longleaf/RegisterEvent.html +628 -0
  66. data/docs/rdocs/Longleaf/RegisteredFileSelector.html +446 -0
  67. data/docs/rdocs/Longleaf/RegistrationError.html +151 -0
  68. data/docs/rdocs/Longleaf/ReindexCommand.html +576 -0
  69. data/docs/rdocs/Longleaf/RsyncReplicationService.html +1180 -0
  70. data/docs/rdocs/Longleaf/SequelIndexDriver.html +1978 -0
  71. data/docs/rdocs/Longleaf/ServiceCandidateFilesystemIterator.html +572 -0
  72. data/docs/rdocs/Longleaf/ServiceCandidateIndexIterator.html +532 -0
  73. data/docs/rdocs/Longleaf/ServiceCandidateLocator.html +333 -0
  74. data/docs/rdocs/Longleaf/ServiceClassCache.html +725 -0
  75. data/docs/rdocs/Longleaf/ServiceDateHelper.html +425 -0
  76. data/docs/rdocs/Longleaf/ServiceDefinition.html +683 -0
  77. data/docs/rdocs/Longleaf/ServiceDefinitionManager.html +371 -0
  78. data/docs/rdocs/Longleaf/ServiceDefinitionValidator.html +269 -0
  79. data/docs/rdocs/Longleaf/ServiceFields.html +173 -0
  80. data/docs/rdocs/Longleaf/ServiceManager.html +1229 -0
  81. data/docs/rdocs/Longleaf/ServiceMappingManager.html +410 -0
  82. data/docs/rdocs/Longleaf/ServiceMappingValidator.html +347 -0
  83. data/docs/rdocs/Longleaf/ServiceRecord.html +821 -0
  84. data/docs/rdocs/Longleaf/StorageLocation.html +985 -0
  85. data/docs/rdocs/Longleaf/StorageLocationManager.html +729 -0
  86. data/docs/rdocs/Longleaf/StorageLocationUnavailableError.html +143 -0
  87. data/docs/rdocs/Longleaf/StorageLocationValidator.html +373 -0
  88. data/docs/rdocs/Longleaf/StoragePathValidator.html +253 -0
  89. data/docs/rdocs/Longleaf/SystemConfigBuilder.html +441 -0
  90. data/docs/rdocs/Longleaf/SystemConfigFields.html +163 -0
  91. data/docs/rdocs/Longleaf/ValidateConfigCommand.html +451 -0
  92. data/docs/rdocs/Longleaf/ValidateMetadataCommand.html +408 -0
  93. data/docs/rdocs/_index.html +660 -0
  94. data/docs/rdocs/class_list.html +51 -0
  95. data/docs/rdocs/css/common.css +1 -0
  96. data/docs/rdocs/css/full_list.css +58 -0
  97. data/docs/rdocs/css/style.css +496 -0
  98. data/docs/rdocs/file.README.html +165 -0
  99. data/docs/rdocs/file_list.html +56 -0
  100. data/docs/rdocs/frames.html +17 -0
  101. data/docs/rdocs/index.html +165 -0
  102. data/docs/rdocs/js/app.js +303 -0
  103. data/docs/rdocs/js/full_list.js +216 -0
  104. data/docs/rdocs/js/jquery.js +4 -0
  105. data/docs/rdocs/method_list.html +2051 -0
  106. data/docs/rdocs/top-level-namespace.html +110 -0
  107. data/lib/longleaf/candidates/file_selector.rb +139 -0
  108. data/lib/longleaf/candidates/manifest_digest_provider.rb +17 -0
  109. data/lib/longleaf/candidates/registered_file_selector.rb +67 -0
  110. data/lib/longleaf/candidates/service_candidate_filesystem_iterator.rb +93 -0
  111. data/lib/longleaf/candidates/service_candidate_index_iterator.rb +84 -0
  112. data/lib/longleaf/candidates/service_candidate_locator.rb +23 -0
  113. data/lib/longleaf/candidates/single_digest_provider.rb +13 -0
  114. data/lib/longleaf/cli.rb +237 -46
  115. data/lib/longleaf/commands/deregister_command.rb +51 -0
  116. data/lib/longleaf/commands/preserve_command.rb +50 -0
  117. data/lib/longleaf/commands/register_command.rb +32 -43
  118. data/lib/longleaf/commands/reindex_command.rb +92 -0
  119. data/lib/longleaf/commands/validate_config_command.rb +33 -8
  120. data/lib/longleaf/commands/validate_metadata_command.rb +51 -0
  121. data/lib/longleaf/errors.rb +26 -7
  122. data/lib/longleaf/events/deregister_event.rb +53 -0
  123. data/lib/longleaf/events/event_names.rb +9 -0
  124. data/lib/longleaf/events/event_status_tracking.rb +59 -0
  125. data/lib/longleaf/events/preserve_event.rb +81 -0
  126. data/lib/longleaf/events/register_event.rb +52 -51
  127. data/lib/longleaf/helpers/case_insensitive_hash.rb +38 -0
  128. data/lib/longleaf/helpers/digest_helper.rb +56 -0
  129. data/lib/longleaf/helpers/s3_uri_helper.rb +86 -0
  130. data/lib/longleaf/helpers/selection_options_parser.rb +189 -0
  131. data/lib/longleaf/helpers/service_date_helper.rb +78 -0
  132. data/lib/longleaf/indexing/index_manager.rb +101 -0
  133. data/lib/longleaf/indexing/sequel_index_driver.rb +306 -0
  134. data/lib/longleaf/logging.rb +5 -4
  135. data/lib/longleaf/logging/redirecting_logger.rb +26 -25
  136. data/lib/longleaf/models/app_fields.rb +7 -2
  137. data/lib/longleaf/models/file_record.rb +17 -8
  138. data/lib/longleaf/models/filesystem_metadata_location.rb +56 -0
  139. data/lib/longleaf/models/filesystem_storage_location.rb +52 -0
  140. data/lib/longleaf/models/md_fields.rb +2 -1
  141. data/lib/longleaf/models/metadata_location.rb +47 -0
  142. data/lib/longleaf/models/metadata_record.rb +39 -15
  143. data/lib/longleaf/models/s3_storage_location.rb +133 -0
  144. data/lib/longleaf/models/service_definition.rb +7 -6
  145. data/lib/longleaf/models/service_fields.rb +7 -1
  146. data/lib/longleaf/models/service_record.rb +10 -6
  147. data/lib/longleaf/models/storage_location.rb +24 -19
  148. data/lib/longleaf/models/storage_types.rb +9 -0
  149. data/lib/longleaf/models/system_config_fields.rb +9 -0
  150. data/lib/longleaf/preservation_services/file_check_service.rb +58 -0
  151. data/lib/longleaf/preservation_services/fixity_check_service.rb +123 -0
  152. data/lib/longleaf/preservation_services/rsync_replication_service.rb +182 -0
  153. data/lib/longleaf/preservation_services/s3_replication_service.rb +143 -0
  154. data/lib/longleaf/services/application_config_deserializer.rb +81 -24
  155. data/lib/longleaf/services/application_config_manager.rb +20 -6
  156. data/lib/longleaf/services/application_config_validator.rb +19 -9
  157. data/lib/longleaf/services/configuration_validator.rb +67 -4
  158. data/lib/longleaf/services/filesystem_location_validator.rb +16 -0
  159. data/lib/longleaf/services/metadata_deserializer.rb +113 -42
  160. data/lib/longleaf/services/metadata_persistence_manager.rb +47 -0
  161. data/lib/longleaf/services/metadata_serializer.rb +138 -25
  162. data/lib/longleaf/services/metadata_validator.rb +76 -0
  163. data/lib/longleaf/services/s3_location_validator.rb +19 -0
  164. data/lib/longleaf/services/service_class_cache.rb +112 -0
  165. data/lib/longleaf/services/service_definition_manager.rb +10 -7
  166. data/lib/longleaf/services/service_definition_validator.rb +25 -18
  167. data/lib/longleaf/services/service_manager.rb +86 -11
  168. data/lib/longleaf/services/service_mapping_manager.rb +13 -12
  169. data/lib/longleaf/services/service_mapping_validator.rb +36 -26
  170. data/lib/longleaf/services/storage_location_manager.rb +76 -15
  171. data/lib/longleaf/services/storage_location_validator.rb +49 -35
  172. data/lib/longleaf/specs/config_builder.rb +47 -23
  173. data/lib/longleaf/specs/config_validator_helpers.rb +16 -0
  174. data/lib/longleaf/specs/custom_matchers.rb +9 -0
  175. data/lib/longleaf/specs/file_helpers.rb +61 -0
  176. data/lib/longleaf/specs/metadata_builder.rb +92 -0
  177. data/lib/longleaf/specs/system_config_builder.rb +27 -0
  178. data/lib/longleaf/version.rb +1 -1
  179. data/longleaf.gemspec +20 -7
  180. data/mkdocs.yml +21 -0
  181. metadata +306 -23
  182. data/.travis.yml +0 -4
  183. data/lib/longleaf/commands/abstract_command.rb +0 -37
  184. data/lib/longleaf/services/storage_path_validator.rb +0 -16
@@ -0,0 +1,691 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Class: Longleaf::FixityCheckService
8
+
9
+ &mdash; Documentation by YARD 0.9.19
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "Longleaf::FixityCheckService";
19
+ relpath = '../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../_index.html">Index (F)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../Longleaf.html" title="Longleaf (module)">Longleaf</a></span></span>
41
+ &raquo;
42
+ <span class="title">FixityCheckService</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Class: Longleaf::FixityCheckService
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Object</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">Longleaf::FixityCheckService</li>
78
+
79
+ </ul>
80
+ <a href="#" class="inheritanceTree">show all</a>
81
+
82
+ </dd>
83
+ </dl>
84
+
85
+
86
+
87
+
88
+
89
+
90
+ <dl>
91
+ <dt>Includes:</dt>
92
+ <dd><span class='object_link'><a href="Logging.html" title="Longleaf::Logging (module)">Logging</a></span></dd>
93
+ </dl>
94
+
95
+
96
+
97
+
98
+
99
+
100
+ <dl>
101
+ <dt>Defined in:</dt>
102
+ <dd>lib/longleaf/preservation_services/fixity_check_service.rb</dd>
103
+ </dl>
104
+
105
+ </div>
106
+
107
+ <h2>Overview</h2><div class="docstring">
108
+ <div class="discussion">
109
+
110
+ <p>Preservation service which performs one or more fixity checks on a file based on the configured list of digest algorithms. It currently supports &#39;md5&#39;, &#39;sha1&#39;, &#39;sha2&#39;, &#39;sha256&#39;, &#39;sha384&#39;, &#39;sha512&#39; and &#39;rmd160&#39;.</p>
111
+
112
+ <p>If the service encounters a file which is missing any of the digest algorithms the service is configured to check, the outcome may be controlled with the &#39;absent_digest&#39; property via the following values:</p>
113
+
114
+ <pre class="code ruby"><code class="ruby">* &#39;fail&#39; - the service will raise a ChecksumMismatchError for the missing algorithm. This is the default.
115
+ * &#39;ignore&#39; - the service will skip calculating any algorithms not already present for the file.
116
+ * &#39;generate&#39; - the service will generate and store any missing digests from the set of configured algorithms.
117
+ </code></pre>
118
+
119
+
120
+ </div>
121
+ </div>
122
+ <div class="tags">
123
+
124
+
125
+ </div>
126
+
127
+ <h2>
128
+ Constant Summary
129
+ <small><a href="#" class="constants_summary_toggle">collapse</a></small>
130
+ </h2>
131
+
132
+ <dl class="constants">
133
+
134
+ <dt id="SUPPORTED_ALGORITHMS-constant" class="">SUPPORTED_ALGORITHMS =
135
+
136
+ </dt>
137
+ <dd><pre class="code"><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>md5</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>sha1</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>sha2</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>sha256</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>sha384</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>sha512</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>rmd160</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span></pre></dd>
138
+
139
+ <dt id="ABSENT_DIGEST_PROPERTY-constant" class="">ABSENT_DIGEST_PROPERTY =
140
+ <div class="docstring">
141
+ <div class="discussion">
142
+
143
+ <p>service configuration property indicating how to handle situations where a file does not have a digest for one of the expected algorithms on record.</p>
144
+
145
+
146
+ </div>
147
+ </div>
148
+ <div class="tags">
149
+
150
+
151
+ </div>
152
+ </dt>
153
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>absent_digest</span><span class='tstring_end'>&#39;</span></span></pre></dd>
154
+
155
+ <dt id="FAIL_IF_ABSENT-constant" class="">FAIL_IF_ABSENT =
156
+
157
+ </dt>
158
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>fail</span><span class='tstring_end'>&#39;</span></span></pre></dd>
159
+
160
+ <dt id="GENERATE_IF_ABSENT-constant" class="">GENERATE_IF_ABSENT =
161
+
162
+ </dt>
163
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>generate</span><span class='tstring_end'>&#39;</span></span></pre></dd>
164
+
165
+ <dt id="IGNORE_IF_ABSENT-constant" class="">IGNORE_IF_ABSENT =
166
+
167
+ </dt>
168
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>ignore</span><span class='tstring_end'>&#39;</span></span></pre></dd>
169
+
170
+ <dt id="ABSENT_DIGEST_OPTIONS-constant" class="">ABSENT_DIGEST_OPTIONS =
171
+
172
+ </dt>
173
+ <dd><pre class="code"><span class='lbracket'>[</span><span class='const'><span class='object_link'><a href="#FAIL_IF_ABSENT-constant" title="Longleaf::FixityCheckService::FAIL_IF_ABSENT (constant)">FAIL_IF_ABSENT</a></span></span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="#GENERATE_IF_ABSENT-constant" title="Longleaf::FixityCheckService::GENERATE_IF_ABSENT (constant)">GENERATE_IF_ABSENT</a></span></span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="#IGNORE_IF_ABSENT-constant" title="Longleaf::FixityCheckService::IGNORE_IF_ABSENT (constant)">IGNORE_IF_ABSENT</a></span></span><span class='rbracket'>]</span></pre></dd>
174
+
175
+ </dl>
176
+
177
+
178
+
179
+
180
+
181
+
182
+
183
+
184
+
185
+ <h2>
186
+ Instance Method Summary
187
+ <small><a href="#" class="summary_toggle">collapse</a></small>
188
+ </h2>
189
+
190
+ <ul class="summary">
191
+
192
+ <li class="public ">
193
+ <span class="summary_signature">
194
+
195
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(service_def, app_manager) &#x21d2; FixityCheckService </a>
196
+
197
+
198
+
199
+ </span>
200
+
201
+
202
+ <span class="note title constructor">constructor</span>
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+ <span class="summary_desc"><div class='inline'>
212
+ <p>Initialize a FixityCheckService from the given service definition.</p>
213
+ </div></span>
214
+
215
+ </li>
216
+
217
+
218
+ <li class="public ">
219
+ <span class="summary_signature">
220
+
221
+ <a href="#is_applicable%3F-instance_method" title="#is_applicable? (instance method)">#<strong>is_applicable?</strong>(event) &#x21d2; Boolean </a>
222
+
223
+
224
+
225
+ </span>
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+ <span class="summary_desc"><div class='inline'>
236
+ <p>Determine if this service is applicable for the provided event, given the configured service definition.</p>
237
+ </div></span>
238
+
239
+ </li>
240
+
241
+
242
+ <li class="public ">
243
+ <span class="summary_signature">
244
+
245
+ <a href="#perform-instance_method" title="#perform (instance method)">#<strong>perform</strong>(file_rec, event) &#x21d2; Object </a>
246
+
247
+
248
+
249
+ </span>
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+ <span class="summary_desc"><div class='inline'>
260
+ <p>Perform all configured fixity checks on the provided file.</p>
261
+ </div></span>
262
+
263
+ </li>
264
+
265
+
266
+ </ul>
267
+
268
+
269
+
270
+
271
+
272
+
273
+
274
+
275
+
276
+
277
+
278
+ <h3 class="inherited">Methods included from <span class='object_link'><a href="Logging.html" title="Longleaf::Logging (module)">Logging</a></span></h3>
279
+ <p class="inherited"><span class='object_link'><a href="Logging.html#initialize_logger-instance_method" title="Longleaf::Logging#initialize_logger (method)">#initialize_logger</a></span>, <span class='object_link'><a href="Logging.html#initialize_logger-class_method" title="Longleaf::Logging.initialize_logger (method)">initialize_logger</a></span>, <span class='object_link'><a href="Logging.html#logger-instance_method" title="Longleaf::Logging#logger (method)">#logger</a></span>, <span class='object_link'><a href="Logging.html#logger-class_method" title="Longleaf::Logging.logger (method)">logger</a></span></p>
280
+ <div id="constructor_details" class="method_details_list">
281
+ <h2>Constructor Details</h2>
282
+
283
+ <div class="method_details first">
284
+ <h3 class="signature first" id="initialize-instance_method">
285
+
286
+ #<strong>initialize</strong>(service_def, app_manager) &#x21d2; <tt><span class='object_link'><a href="" title="Longleaf::FixityCheckService (class)">FixityCheckService</a></span></tt>
287
+
288
+
289
+
290
+
291
+
292
+ </h3><div class="docstring">
293
+ <div class="discussion">
294
+
295
+ <p>Initialize a FixityCheckService from the given service definition</p>
296
+
297
+
298
+ </div>
299
+ </div>
300
+ <div class="tags">
301
+ <p class="tag_title">Parameters:</p>
302
+ <ul class="param">
303
+
304
+ <li>
305
+
306
+ <span class='name'>service_def</span>
307
+
308
+
309
+ <span class='type'>(<tt><span class='object_link'><a href="ServiceDefinition.html" title="Longleaf::ServiceDefinition (class)">ServiceDefinition</a></span></tt>)</span>
310
+
311
+
312
+
313
+ &mdash;
314
+ <div class='inline'>
315
+ <p>the configuration for this service</p>
316
+ </div>
317
+
318
+ </li>
319
+
320
+ <li>
321
+
322
+ <span class='name'>app_manager</span>
323
+
324
+
325
+ <span class='type'>(<tt><span class='object_link'><a href="ApplicationConfigManager.html" title="Longleaf::ApplicationConfigManager (class)">ApplicationConfigManager</a></span></tt>)</span>
326
+
327
+
328
+
329
+ &mdash;
330
+ <div class='inline'>
331
+ <p>manager for configured storage locations</p>
332
+ </div>
333
+
334
+ </li>
335
+
336
+ </ul>
337
+
338
+
339
+ </div><table class="source_code">
340
+ <tr>
341
+ <td>
342
+ <pre class="lines">
343
+
344
+
345
+ 33
346
+ 34
347
+ 35
348
+ 36
349
+ 37
350
+ 38
351
+ 39
352
+ 40
353
+ 41
354
+ 42
355
+ 43
356
+ 44
357
+ 45
358
+ 46
359
+ 47
360
+ 48
361
+ 49
362
+ 50
363
+ 51
364
+ 52
365
+ 53
366
+ 54
367
+ 55
368
+ 56
369
+ 57</pre>
370
+ </td>
371
+ <td>
372
+ <pre class="code"><span class="info file"># File 'lib/longleaf/preservation_services/fixity_check_service.rb', line 33</span>
373
+
374
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_service_def'>service_def</span><span class='comma'>,</span> <span class='id identifier rubyid_app_manager'>app_manager</span><span class='rparen'>)</span>
375
+ <span class='ivar'>@service_def</span> <span class='op'>=</span> <span class='id identifier rubyid_service_def'>service_def</span>
376
+ <span class='ivar'>@absent_digest_behavior</span> <span class='op'>=</span> <span class='ivar'>@service_def</span><span class='period'>.</span><span class='id identifier rubyid_properties'>properties</span><span class='lbracket'>[</span><span class='const'><span class='object_link'><a href="#ABSENT_DIGEST_PROPERTY-constant" title="Longleaf::FixityCheckService::ABSENT_DIGEST_PROPERTY (constant)">ABSENT_DIGEST_PROPERTY</a></span></span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='const'><span class='object_link'><a href="#FAIL_IF_ABSENT-constant" title="Longleaf::FixityCheckService::FAIL_IF_ABSENT (constant)">FAIL_IF_ABSENT</a></span></span>
377
+ <span class='kw'>unless</span> <span class='const'><span class='object_link'><a href="#ABSENT_DIGEST_OPTIONS-constant" title="Longleaf::FixityCheckService::ABSENT_DIGEST_OPTIONS (constant)">ABSENT_DIGEST_OPTIONS</a></span></span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='ivar'>@absent_digest_behavior</span><span class='rparen'>)</span>
378
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Invalid option &#39;</span><span class='embexpr_beg'>#{</span><span class='ivar'>@absent_digest_behavior</span><span class='embexpr_end'>}</span><span class='tstring_content'>&#39; for property </span><span class='embexpr_beg'>#{</span><span class='const'><span class='object_link'><a href="#ABSENT_DIGEST_PROPERTY-constant" title="Longleaf::FixityCheckService::ABSENT_DIGEST_PROPERTY (constant)">ABSENT_DIGEST_PROPERTY</a></span></span><span class='embexpr_end'>}</span><span class='tstring_content'> in service </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_service_def'>service_def</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
379
+ <span class='kw'>end</span>
380
+
381
+ <span class='id identifier rubyid_service_algs'>service_algs</span> <span class='op'>=</span> <span class='id identifier rubyid_service_def'>service_def</span><span class='period'>.</span><span class='id identifier rubyid_properties'>properties</span><span class='lbracket'>[</span><span class='const'><span class='object_link'><a href="ServiceFields.html" title="Longleaf::ServiceFields (class)">ServiceFields</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="ServiceFields.html#DIGEST_ALGORITHMS-constant" title="Longleaf::ServiceFields::DIGEST_ALGORITHMS (constant)">DIGEST_ALGORITHMS</a></span></span><span class='rbracket'>]</span>
382
+ <span class='kw'>if</span> <span class='id identifier rubyid_service_algs'>service_algs</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>||</span> <span class='id identifier rubyid_service_algs'>service_algs</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
383
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>FixityCheckService from definition </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_service_def'>service_def</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_content'> requires a list of one or more digest algorithms</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
384
+ <span class='kw'>end</span>
385
+
386
+ <span class='id identifier rubyid_service_algs'>service_algs</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_service_algs'>service_algs</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='id identifier rubyid_service_algs'>service_algs</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span>
387
+
388
+ <span class='comment'># Store the list of digest algorithms to verify, using normalized algorithm names.
389
+ </span> <span class='ivar'>@digest_algs</span> <span class='op'>=</span> <span class='const'>Set</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
390
+ <span class='id identifier rubyid_service_algs'>service_algs</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_alg'>alg</span><span class='op'>|</span>
391
+ <span class='id identifier rubyid_normalized_alg'>normalized_alg</span> <span class='op'>=</span> <span class='id identifier rubyid_alg'>alg</span><span class='period'>.</span><span class='id identifier rubyid_downcase'>downcase</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>-</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
392
+ <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="#SUPPORTED_ALGORITHMS-constant" title="Longleaf::FixityCheckService::SUPPORTED_ALGORITHMS (constant)">SUPPORTED_ALGORITHMS</a></span></span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_normalized_alg'>normalized_alg</span><span class='rparen'>)</span>
393
+ <span class='ivar'>@digest_algs</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_normalized_alg'>normalized_alg</span>
394
+ <span class='kw'>else</span>
395
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Unsupported checksum algorithm &#39;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_alg'>alg</span><span class='embexpr_end'>}</span><span class='tstring_content'>&#39; in definition </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_service_def'>service_def</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_content'>. Supported algorithms are: </span><span class='embexpr_beg'>#{</span><span class='const'><span class='object_link'><a href="#SUPPORTED_ALGORITHMS-constant" title="Longleaf::FixityCheckService::SUPPORTED_ALGORITHMS (constant)">SUPPORTED_ALGORITHMS</a></span></span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
396
+ <span class='kw'>end</span>
397
+ <span class='kw'>end</span>
398
+ <span class='kw'>end</span></pre>
399
+ </td>
400
+ </tr>
401
+ </table>
402
+ </div>
403
+
404
+ </div>
405
+
406
+
407
+ <div id="instance_method_details" class="method_details_list">
408
+ <h2>Instance Method Details</h2>
409
+
410
+
411
+ <div class="method_details first">
412
+ <h3 class="signature first" id="is_applicable?-instance_method">
413
+
414
+ #<strong>is_applicable?</strong>(event) &#x21d2; <tt>Boolean</tt>
415
+
416
+
417
+
418
+
419
+
420
+ </h3><div class="docstring">
421
+ <div class="discussion">
422
+
423
+ <p>Determine if this service is applicable for the provided event, given the configured service definition</p>
424
+
425
+
426
+ </div>
427
+ </div>
428
+ <div class="tags">
429
+ <p class="tag_title">Parameters:</p>
430
+ <ul class="param">
431
+
432
+ <li>
433
+
434
+ <span class='name'>event</span>
435
+
436
+
437
+ <span class='type'>(<tt>String</tt>)</span>
438
+
439
+
440
+
441
+ &mdash;
442
+ <div class='inline'>
443
+ <p>name of the event</p>
444
+ </div>
445
+
446
+ </li>
447
+
448
+ </ul>
449
+
450
+ <p class="tag_title">Returns:</p>
451
+ <ul class="return">
452
+
453
+ <li>
454
+
455
+
456
+ <span class='type'>(<tt>Boolean</tt>)</span>
457
+
458
+
459
+
460
+ &mdash;
461
+ <div class='inline'>
462
+ <p>returns true if this service is applicable for the provided event</p>
463
+ </div>
464
+
465
+ </li>
466
+
467
+ </ul>
468
+
469
+ </div><table class="source_code">
470
+ <tr>
471
+ <td>
472
+ <pre class="lines">
473
+
474
+
475
+ 114
476
+ 115
477
+ 116
478
+ 117
479
+ 118
480
+ 119
481
+ 120
482
+ 121</pre>
483
+ </td>
484
+ <td>
485
+ <pre class="code"><span class="info file"># File 'lib/longleaf/preservation_services/fixity_check_service.rb', line 114</span>
486
+
487
+ <span class='kw'>def</span> <span class='id identifier rubyid_is_applicable?'>is_applicable?</span><span class='lparen'>(</span><span class='id identifier rubyid_event'>event</span><span class='rparen'>)</span>
488
+ <span class='kw'>case</span> <span class='id identifier rubyid_event'>event</span>
489
+ <span class='kw'>when</span> <span class='const'><span class='object_link'><a href="EventNames.html" title="Longleaf::EventNames (class)">EventNames</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="EventNames.html#PRESERVE-constant" title="Longleaf::EventNames::PRESERVE (constant)">PRESERVE</a></span></span>
490
+ <span class='kw'>true</span>
491
+ <span class='kw'>else</span>
492
+ <span class='kw'>false</span>
493
+ <span class='kw'>end</span>
494
+ <span class='kw'>end</span></pre>
495
+ </td>
496
+ </tr>
497
+ </table>
498
+ </div>
499
+
500
+ <div class="method_details ">
501
+ <h3 class="signature " id="perform-instance_method">
502
+
503
+ #<strong>perform</strong>(file_rec, event) &#x21d2; <tt>Object</tt>
504
+
505
+
506
+
507
+
508
+
509
+ </h3><div class="docstring">
510
+ <div class="discussion">
511
+
512
+ <p>Perform all configured fixity checks on the provided file</p>
513
+
514
+
515
+ </div>
516
+ </div>
517
+ <div class="tags">
518
+ <p class="tag_title">Parameters:</p>
519
+ <ul class="param">
520
+
521
+ <li>
522
+
523
+ <span class='name'>file_rec</span>
524
+
525
+
526
+ <span class='type'>(<tt><span class='object_link'><a href="FileRecord.html" title="Longleaf::FileRecord (class)">FileRecord</a></span></tt>)</span>
527
+
528
+
529
+
530
+ &mdash;
531
+ <div class='inline'>
532
+ <p>record representing the file to perform the service on.</p>
533
+ </div>
534
+
535
+ </li>
536
+
537
+ <li>
538
+
539
+ <span class='name'>event</span>
540
+
541
+
542
+ <span class='type'>(<tt>String</tt>)</span>
543
+
544
+
545
+
546
+ &mdash;
547
+ <div class='inline'>
548
+ <p>name of the event this service is being invoked by.</p>
549
+ </div>
550
+
551
+ </li>
552
+
553
+ </ul>
554
+
555
+ <p class="tag_title">Raises:</p>
556
+ <ul class="raise">
557
+
558
+ <li>
559
+
560
+
561
+ <span class='type'>(<tt><span class='object_link'><a href="ChecksumMismatchError.html" title="Longleaf::ChecksumMismatchError (class)">ChecksumMismatchError</a></span></tt>)</span>
562
+
563
+
564
+
565
+ &mdash;
566
+ <div class='inline'>
567
+ <p>if the checksum on record does not match the generated checksum</p>
568
+ </div>
569
+
570
+ </li>
571
+
572
+ </ul>
573
+
574
+ </div><table class="source_code">
575
+ <tr>
576
+ <td>
577
+ <pre class="lines">
578
+
579
+
580
+ 64
581
+ 65
582
+ 66
583
+ 67
584
+ 68
585
+ 69
586
+ 70
587
+ 71
588
+ 72
589
+ 73
590
+ 74
591
+ 75
592
+ 76
593
+ 77
594
+ 78
595
+ 79
596
+ 80
597
+ 81
598
+ 82
599
+ 83
600
+ 84
601
+ 85
602
+ 86
603
+ 87
604
+ 88
605
+ 89
606
+ 90
607
+ 91
608
+ 92
609
+ 93
610
+ 94
611
+ 95
612
+ 96
613
+ 97
614
+ 98
615
+ 99
616
+ 100
617
+ 101
618
+ 102
619
+ 103
620
+ 104
621
+ 105
622
+ 106
623
+ 107
624
+ 108</pre>
625
+ </td>
626
+ <td>
627
+ <pre class="code"><span class="info file"># File 'lib/longleaf/preservation_services/fixity_check_service.rb', line 64</span>
628
+
629
+ <span class='kw'>def</span> <span class='id identifier rubyid_perform'>perform</span><span class='lparen'>(</span><span class='id identifier rubyid_file_rec'>file_rec</span><span class='comma'>,</span> <span class='id identifier rubyid_event'>event</span><span class='rparen'>)</span>
630
+ <span class='id identifier rubyid_path'>path</span> <span class='op'>=</span> <span class='id identifier rubyid_file_rec'>file_rec</span><span class='period'>.</span><span class='id identifier rubyid_path'>path</span>
631
+ <span class='id identifier rubyid_md_rec'>md_rec</span> <span class='op'>=</span> <span class='id identifier rubyid_file_rec'>file_rec</span><span class='period'>.</span><span class='id identifier rubyid_metadata_record'>metadata_record</span>
632
+
633
+ <span class='comment'># Get the list of existing checksums for the file and normalize algorithm names
634
+ </span> <span class='id identifier rubyid_file_digests'>file_digests</span> <span class='op'>=</span> <span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
635
+ <span class='id identifier rubyid_md_rec'>md_rec</span><span class='period'>.</span><span class='id identifier rubyid_checksums'>checksums</span><span class='op'>&amp;.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_alg'>alg</span><span class='comma'>,</span> <span class='id identifier rubyid_digest'>digest</span><span class='op'>|</span>
636
+ <span class='id identifier rubyid_normalized_alg'>normalized_alg</span> <span class='op'>=</span> <span class='id identifier rubyid_alg'>alg</span><span class='period'>.</span><span class='id identifier rubyid_downcase'>downcase</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>-</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
637
+ <span class='kw'>if</span> <span class='ivar'>@digest_algs</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_normalized_alg'>normalized_alg</span><span class='rparen'>)</span>
638
+ <span class='id identifier rubyid_file_digests'>file_digests</span><span class='lbracket'>[</span><span class='id identifier rubyid_normalized_alg'>normalized_alg</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_digest'>digest</span>
639
+ <span class='kw'>else</span>
640
+ <span class='id identifier rubyid_logger'>logger</span><span class='period'>.</span><span class='id identifier rubyid_debug'>debug</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Metadata for file </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_path'>path</span><span class='embexpr_end'>}</span><span class='tstring_content'> contains unexpected &#39;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_alg'>alg</span><span class='embexpr_end'>}</span><span class='tstring_content'>&#39; digest, it will be ignored.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
641
+ <span class='kw'>end</span>
642
+ <span class='kw'>end</span>
643
+
644
+ <span class='ivar'>@digest_algs</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_alg'>alg</span><span class='op'>|</span>
645
+ <span class='id identifier rubyid_existing_digest'>existing_digest</span> <span class='op'>=</span> <span class='id identifier rubyid_file_digests'>file_digests</span><span class='lbracket'>[</span><span class='id identifier rubyid_alg'>alg</span><span class='rbracket'>]</span>
646
+
647
+ <span class='kw'>if</span> <span class='id identifier rubyid_existing_digest'>existing_digest</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
648
+ <span class='kw'>if</span> <span class='ivar'>@absent_digest_behavior</span> <span class='op'>==</span> <span class='const'><span class='object_link'><a href="#FAIL_IF_ABSENT-constant" title="Longleaf::FixityCheckService::FAIL_IF_ABSENT (constant)">FAIL_IF_ABSENT</a></span></span>
649
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="ChecksumMismatchError.html" title="Longleaf::ChecksumMismatchError (class)">ChecksumMismatchError</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Fixity check using algorithm &#39;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_alg'>alg</span><span class='embexpr_end'>}</span><span class='tstring_content'>&#39; failed for file </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_path'>path</span><span class='embexpr_end'>}</span><span class='tstring_content'>: no existing digest of type &#39;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_alg'>alg</span><span class='embexpr_end'>}</span><span class='tstring_content'>&#39; on record.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
650
+ <span class='kw'>elsif</span> <span class='ivar'>@absent_digest_behavior</span> <span class='op'>==</span> <span class='const'><span class='object_link'><a href="#IGNORE_IF_ABSENT-constant" title="Longleaf::FixityCheckService::IGNORE_IF_ABSENT (constant)">IGNORE_IF_ABSENT</a></span></span>
651
+ <span class='id identifier rubyid_logger'>logger</span><span class='period'>.</span><span class='id identifier rubyid_debug'>debug</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Skipping check of algorithm &#39;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_alg'>alg</span><span class='embexpr_end'>}</span><span class='tstring_content'>&#39; for file </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_path'>path</span><span class='embexpr_end'>}</span><span class='tstring_content'>: no digest on record.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
652
+ <span class='kw'>next</span>
653
+ <span class='kw'>end</span>
654
+ <span class='kw'>end</span>
655
+
656
+ <span class='id identifier rubyid_digest'>digest</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="DigestHelper.html" title="Longleaf::DigestHelper (class)">DigestHelper</a></span></span><span class='op'>::</span><span class='id identifier rubyid_start_digest'><span class='object_link'><a href="DigestHelper.html#start_digest-class_method" title="Longleaf::DigestHelper.start_digest (method)">start_digest</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_alg'>alg</span><span class='rparen'>)</span>
657
+ <span class='id identifier rubyid_digest'>digest</span><span class='period'>.</span><span class='id identifier rubyid_file'>file</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span>
658
+ <span class='id identifier rubyid_generated_digest'>generated_digest</span> <span class='op'>=</span> <span class='id identifier rubyid_digest'>digest</span><span class='period'>.</span><span class='id identifier rubyid_hexdigest'>hexdigest</span>
659
+
660
+ <span class='comment'># Store the missing checksum if using the &#39;generate&#39; behavior
661
+ </span> <span class='kw'>if</span> <span class='id identifier rubyid_existing_digest'>existing_digest</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&amp;&amp;</span> <span class='ivar'>@absent_digest_behavior</span> <span class='op'>==</span> <span class='const'><span class='object_link'><a href="#GENERATE_IF_ABSENT-constant" title="Longleaf::FixityCheckService::GENERATE_IF_ABSENT (constant)">GENERATE_IF_ABSENT</a></span></span>
662
+ <span class='id identifier rubyid_md_rec'>md_rec</span><span class='period'>.</span><span class='id identifier rubyid_checksums'>checksums</span><span class='lbracket'>[</span><span class='id identifier rubyid_alg'>alg</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_generated_digest'>generated_digest</span>
663
+ <span class='id identifier rubyid_logger'>logger</span><span class='period'>.</span><span class='id identifier rubyid_info'>info</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Generated and stored digest using algorithm &#39;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_alg'>alg</span><span class='embexpr_end'>}</span><span class='tstring_content'>&#39; for file </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_path'>path</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
664
+ <span class='kw'>else</span>
665
+ <span class='comment'># Compare the new digest to the one on record
666
+ </span> <span class='kw'>if</span> <span class='id identifier rubyid_existing_digest'>existing_digest</span> <span class='op'>==</span> <span class='id identifier rubyid_generated_digest'>generated_digest</span>
667
+ <span class='id identifier rubyid_logger'>logger</span><span class='period'>.</span><span class='id identifier rubyid_info'>info</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Fixity check using algorithm &#39;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_alg'>alg</span><span class='embexpr_end'>}</span><span class='tstring_content'>&#39; succeeded for file </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_path'>path</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
668
+ <span class='kw'>else</span>
669
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="ChecksumMismatchError.html" title="Longleaf::ChecksumMismatchError (class)">ChecksumMismatchError</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Fixity check using algorithm &#39;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_alg'>alg</span><span class='embexpr_end'>}</span><span class='tstring_content'>&#39; failed for file </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_path'>path</span><span class='embexpr_end'>}</span><span class='tstring_content'>: expected &#39;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_existing_digest'>existing_digest</span><span class='embexpr_end'>}</span><span class='tstring_content'>&#39;, calculated &#39;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_generated_digest'>generated_digest</span><span class='embexpr_end'>}</span><span class='tstring_content'>.&#39;</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
670
+ <span class='kw'>end</span>
671
+ <span class='kw'>end</span>
672
+ <span class='kw'>end</span>
673
+ <span class='kw'>end</span></pre>
674
+ </td>
675
+ </tr>
676
+ </table>
677
+ </div>
678
+
679
+ </div>
680
+
681
+ </div>
682
+
683
+ <div id="footer">
684
+ Generated on Tue May 28 15:48:03 2019 by
685
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
686
+ 0.9.19 (ruby-2.6.3).
687
+ </div>
688
+
689
+ </div>
690
+ </body>
691
+ </html>