We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a73bbd5 commit 287b5b1Copy full SHA for 287b5b1
1 file changed
common/hf-cache.cpp
@@ -26,6 +26,8 @@ namespace nl = nlohmann;
26
#include <windows.h>
27
#else
28
#define HOME_DIR "HOME"
29
+#include <unistd.h>
30
+#include <pwd.h>
31
#endif
32
33
namespace hf_cache {
@@ -51,6 +53,13 @@ static fs::path get_cache_directory() {
51
53
return entry.path.empty() ? base : base / entry.path;
52
54
}
55
56
+#ifndef _WIN32
57
+ const struct passwd * pw = getpwuid(getuid());
58
+
59
+ if (pw->pw_dir && *pw->pw_dir) {
60
+ return fs::path(pw->pw_dir) / ".cache" / "huggingface" / "hub";
61
+ }
62
+#endif
63
throw std::runtime_error("Failed to determine HF cache directory");
64
}();
65
0 commit comments