Skip to content

Commit 9fd116d

Browse files
committed
Handle directory.
1 parent a78db2c commit 9fd116d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/data/sparse_page_source.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ void TryDeleteCacheFile(const std::string& file) {
3131
}
3232

3333
std::string MakeCachePrefix(std::string cache_prefix) {
34-
cache_prefix = cache_prefix.empty() ? "DMatrix" : cache_prefix;
34+
std::string_view constexpr kDftname{"DMatrix"};
35+
cache_prefix = cache_prefix.empty() ? kDftname : cache_prefix;
36+
// Use the directory if one exists
37+
if (std::filesystem::is_directory(cache_prefix)) {
38+
cache_prefix = std::filesystem::path{cache_prefix} / kDftname;
39+
}
40+
// Avoid conflicts in distributed environments.
3541
if (collective::IsDistributed()) {
3642
cache_prefix += ("-r" + std::to_string(collective::GetRank()));
3743
}

0 commit comments

Comments
 (0)