| 625 | |
| 626 | |
| 627 | Try<MemoryProfiler::DiskArtifact> MemoryProfiler::DiskArtifact::create( |
| 628 | const string& filename, |
| 629 | time_t timestamp, |
| 630 | std::function<Try<Nothing>(const string&)> generator) |
| 631 | { |
| 632 | Try<Path> tmpdir = getTemporaryDirectoryPath(); |
| 633 | if (tmpdir.isError()) { |
| 634 | return Error("Could not determine target path: " + tmpdir.error()); |
| 635 | } |
| 636 | |
| 637 | const string path = path::join(tmpdir.get(), filename); |
| 638 | |
| 639 | Try<Nothing> result = generator(path); |
| 640 | |
| 641 | if (result.isError()) { |
| 642 | // The old file might still be fine on disk, but there's no good way to |
| 643 | // verify this hence we assume that the error rendered it unusable. |
| 644 | return Error("Failed to create artifact: " + result.error()); |
| 645 | } |
| 646 | |
| 647 | return MemoryProfiler::DiskArtifact(path, timestamp); |
| 648 | } |
| 649 | |
| 650 | |
| 651 | MemoryProfiler::MemoryProfiler(const Option<string>& _authenticationRealm) |
nothing calls this directly
no test coverage detected