Skip to content

Commit 75bec64

Browse files
committed
fix: apply suggestion by @coyotte508
1 parent 57df98e commit 75bec64

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

packages/hub/src/lib/cache-management.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function getHuggingFaceHubCache(): string {
1616
return process.env["HUGGINGFACE_HUB_CACHE"] ?? getDefaultCachePath();
1717
}
1818

19-
export function getHFHubCache(): string {
19+
export function getHFHubCachePath(): string {
2020
return process.env["HF_HUB_CACHE"] ?? getHuggingFaceHubCache();
2121
}
2222

@@ -70,7 +70,7 @@ export interface HFCacheInfo {
7070
}
7171

7272
export async function scanCacheDir(cacheDir: string | undefined = undefined): Promise<HFCacheInfo> {
73-
if (!cacheDir) cacheDir = getHFHubCache();
73+
if (!cacheDir) cacheDir = getHFHubCachePath();
7474

7575
const s = await stat(cacheDir);
7676
if (!s.isDirectory()) {

packages/hub/src/lib/download-file-cache.spec.ts renamed to packages/hub/src/lib/download-file-to-cache-dir.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { dirname, join } from "node:path";
44
import { lstat, mkdir, stat, symlink, writeFile, rename } from "node:fs/promises";
55
import { pathsInfo } from "./paths-info";
66
import type { Stats } from "node:fs";
7-
import { getHFHubCache, getRepoFolderName } from "./cache-management";
7+
import { getHFHubCachePath, getRepoFolderName } from "./cache-management";
88
import { toRepoId } from "../utils/toRepoId";
9-
import { downloadFileToCacheDir } from "./download-file-cache";
9+
import { downloadFileToCacheDir } from "./download-file-to-cache-dir";
1010

1111
vi.mock('node:fs/promises', () => ({
1212
writeFile: vi.fn(),
@@ -34,7 +34,7 @@ function _getBlobFile(params: {
3434
etag: string;
3535
cacheDir?: string, // default to {@link getHFHubCache}
3636
}) {
37-
return join(params.cacheDir ?? getHFHubCache(), getRepoFolderName(toRepoId(params.repo)), "blobs", params.etag);
37+
return join(params.cacheDir ?? getHFHubCachePath(), getRepoFolderName(toRepoId(params.repo)), "blobs", params.etag);
3838
}
3939

4040
// utility test method to get snapshot file path
@@ -44,7 +44,7 @@ function _getSnapshotFile(params: {
4444
revision : string;
4545
cacheDir?: string, // default to {@link getHFHubCache}
4646
}) {
47-
return join(params.cacheDir ?? getHFHubCache(), getRepoFolderName(toRepoId(params.repo)), "snapshots", params.revision, params.path);
47+
return join(params.cacheDir ?? getHFHubCachePath(), getRepoFolderName(toRepoId(params.repo)), "snapshots", params.revision, params.path);
4848
}
4949

5050
describe('downloadFileToCacheDir', () => {

packages/hub/src/lib/download-file-cache.ts renamed to packages/hub/src/lib/download-file-to-cache-dir.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getHFHubCache, getRepoFolderName } from "./cache-management";
1+
import { getHFHubCachePath, getRepoFolderName } from "./cache-management";
22
import { dirname, join } from "node:path";
33
import { writeFile, rename, symlink, lstat, mkdir, stat } from "node:fs/promises";
44
import type { CommitInfo, PathInfo } from "./paths-info";
@@ -63,7 +63,7 @@ export async function downloadFileToCacheDir(
6363
): Promise<string> {
6464
// get revision provided or default to main
6565
const revision = params.revision ?? "main";
66-
const cacheDir = params.cacheDir ?? getHFHubCache();
66+
const cacheDir = params.cacheDir ?? getHFHubCachePath();
6767
// get repo id
6868
const repoId = toRepoId(params.repo);
6969
// get storage folder

packages/hub/src/lib/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export * from "./delete-file";
88
export * from "./delete-files";
99
export * from "./delete-repo";
1010
export * from "./download-file";
11-
export * from "./download-file-cache";
11+
export * from "./download-file-to-cache-dir";
1212
export * from "./file-download-info";
1313
export * from "./file-exists";
1414
export * from "./list-commits";

0 commit comments

Comments
 (0)