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

Function createCacheDirectory

src/launcher/fetcher.cpp:480–518  ·  view source on GitHub ↗

Checks to see if it's necessary to create a fetcher cache directory for this user, and creates it if so.

Source from the content-addressed store, hash-verified

478// Checks to see if it's necessary to create a fetcher cache directory for this
479// user, and creates it if so.
480static Try<Nothing> createCacheDirectory(const FetcherInfo& fetcherInfo)
481{
482 if (!fetcherInfo.has_cache_directory()) {
483 return Nothing();
484 }
485
486 foreach (const FetcherInfo::Item& item, fetcherInfo.items()) {
487 if (item.action() != FetcherInfo::Item::BYPASS_CACHE) {
488 // If this user has fetched anything into the cache before, their cache
489 // directory will already exist. Set `recursive = true` when calling
490 // `os::mkdir` to ensure no error is returned in this case.
491 Try<Nothing> mkdir = os::mkdir(fetcherInfo.cache_directory(), true);
492 if (mkdir.isError()) {
493 return mkdir;
494 }
495
496 if (fetcherInfo.has_user()) {
497 // Fetching is performed as the task's user,
498 // so chown the cache directory.
499
500 // TODO(coffler): Fix Windows chown handling, see MESOS-8063.
501#ifndef __WINDOWS__
502 Try<Nothing> chown = os::chown(
503 fetcherInfo.user(),
504 fetcherInfo.cache_directory(),
505 false);
506
507 if (chown.isError()) {
508 return chown;
509 }
510#endif // __WINDOWS__
511 }
512
513 break;
514 }
515 }
516
517 return Nothing();
518}
519
520
521// This "fetcher program" is invoked by the slave's fetcher actor

Callers 1

mainFunction · 0.85

Calls 1

NothingClass · 0.85

Tested by

no test coverage detected