MCPcopy Create free account
hub / github.com/apache/mesos / fetchBypassingCache

Function fetchBypassingCache

src/launcher/fetcher.cpp:284–339  ·  view source on GitHub ↗

Returns the resulting file or in case of extraction the destination directory (for logging).

Source from the content-addressed store, hash-verified

282// Returns the resulting file or in case of extraction the destination
283// directory (for logging).
284static Try<string> fetchBypassingCache(
285 const CommandInfo::URI& uri,
286 const string& sandboxDirectory,
287 const Option<string>& frameworksHome,
288 const Option<Duration>& stallTimeout)
289{
290 LOG(INFO) << "Fetching '" << uri.value()
291 << "' directly into the sandbox directory";
292
293 // TODO(mrbrowning): Factor out duplicated processing of "output_file" field
294 // here and in fetchFromCache into a separate helper function.
295 if (uri.has_output_file()) {
296 string dirname = Path(uri.output_file()).dirname();
297 if (dirname != ".") {
298 Try<Nothing> result =
299 os::mkdir(path::join(sandboxDirectory, dirname), true);
300
301 if (result.isError()) {
302 return Error(
303 "Unable to create subdirectory " + dirname +
304 " in sandbox: " + result.error());
305 }
306 }
307 }
308
309 Try<string> outputFile = uri.has_output_file()
310 ? uri.output_file()
311 : Fetcher::basename(uri.value());
312
313 if (outputFile.isError()) {
314 return Error(outputFile.error());
315 }
316
317 string path = path::join(sandboxDirectory, outputFile.get());
318
319 Try<string> downloaded =
320 download(uri.value(), path, frameworksHome, stallTimeout);
321 if (downloaded.isError()) {
322 return Error(downloaded.error());
323 }
324
325 if (uri.executable()) {
326 return chmodExecutable(downloaded.get());
327 } else if (uri.extract()) {
328 Try<bool> extracted = extract(path, sandboxDirectory);
329 if (extracted.isError()) {
330 return Error(extracted.error());
331 } else if (!extracted.get()) {
332 LOG(WARNING) << "Copying instead of extracting resource from URI with "
333 << "'extract' flag, because it does not seem to be an "
334 << "archive: " << uri.value();
335 }
336 }
337
338 return downloaded;
339}
340
341

Callers 1

fetchFunction · 0.85

Calls 13

PathClass · 0.85
chmodExecutableFunction · 0.85
dirnameMethod · 0.80
downloadFunction · 0.70
extractFunction · 0.70
errorMethod · 0.65
mkdirFunction · 0.50
joinFunction · 0.50
ErrorFunction · 0.50
valueMethod · 0.45
isErrorMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected