File tree 2 files changed +47
-0
lines changed
lib/src/main/kotlin/org/veupathdb/lib/compute/platform
2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -203,6 +203,24 @@ object AsyncPlatform {
203
203
return S3 .getNonReservedFiles(jobID)
204
204
}
205
205
206
+ /* *
207
+ * Fetches the target file for the target job.
208
+ *
209
+ * If the target file does not exist, this method returns `null`.
210
+ *
211
+ * @param jobID Hash ID of the job whose file should be retrieved.
212
+ *
213
+ * @param fileName Name of the file to retrieve.
214
+ *
215
+ * @return A reference to the target file, if it exists, otherwise `null`.
216
+ *
217
+ * @since 1.5.0
218
+ */
219
+ fun getJobFile (jobID : HashID , fileName : String ): JobFileReference ? {
220
+ Log .debug(" fetching target file \" {}\" for job {}" , jobID, fileName)
221
+ return S3 .getJobFile(jobID, fileName)
222
+ }
223
+
206
224
/* *
207
225
* Deletes the target job only if it exists, is owned by the current service
208
226
* or process, and is in a completed status.
Original file line number Diff line number Diff line change @@ -186,6 +186,35 @@ internal object S3 {
186
186
return out
187
187
}
188
188
189
+ /* *
190
+ * Attempts to fetch the target file from the target workspace.
191
+ *
192
+ * If the target workspace is not found, an [IllegalStateException] will be
193
+ * thrown.
194
+ *
195
+ * If the target file is not found, `null` will be returned.
196
+ *
197
+ * @param jobID ID of the workspace from which the target job should be
198
+ * fetched.
199
+ *
200
+ * @return A handle on the target file, if it exists, or `null`.
201
+ *
202
+ * @since 1.5.0
203
+ */
204
+ @JvmStatic
205
+ fun getJobFile (jobID : HashID , fileName : String ): JobFileReference ? {
206
+ Log .debug(" fetching target file \" {}\" for job {} in S3" , fileName, jobID)
207
+
208
+ // Load the workspace
209
+ val ws = wsf[jobID] ? : throw IllegalStateException (" attempted to fetch target file from nonexistent workspace $jobID " )
210
+
211
+ // Sift through the files for one matching the target file name and return
212
+ // it (or null if none were found).
213
+ return ws.files()
214
+ .firstOrNull { it.name == fileName }
215
+ ?.let (::JobFileReferenceImpl )
216
+ }
217
+
189
218
/* *
190
219
* Clears out the target workspace and marks it as `expired`.
191
220
*
You can’t perform that action at this time.
0 commit comments