MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / getStorageBasePath

Function getStorageBasePath

src/utils/storage.ts:14–48  ·  view source on GitHub ↗
(defaultPath: string)

Source from the content-addressed store, hash-verified

12 * Otherwise uses the default VSCode extension global storage path
13 */
14export async function getStorageBasePath(defaultPath: string): Promise<string> {
15 // Get user-configured custom storage path
16 let customStoragePath = ""
17
18 try {
19 // This is the line causing the error in tests
20 const config = vscode.workspace.getConfiguration(Package.name)
21 customStoragePath = config.get<string>("customStoragePath", "")
22 } catch (error) {
23 console.warn("Could not access VSCode configuration - using default path")
24 return defaultPath
25 }
26
27 // If no custom path is set, use default path
28 if (!customStoragePath) {
29 return defaultPath
30 }
31
32 try {
33 // Ensure custom path exists
34 await fs.mkdir(customStoragePath, { recursive: true })
35
36 // Check directory write permission without creating temp files
37 await fs.access(customStoragePath, fsConstants.R_OK | fsConstants.W_OK | fsConstants.X_OK)
38
39 return customStoragePath
40 } catch (error) {
41 // If path is unusable, report error and fall back to default path
42 console.error(`Custom storage path is unusable: ${error instanceof Error ? error.message : String(error)}`)
43 if (vscode.window) {
44 vscode.window.showErrorMessage(t("common:errors.custom_storage_path_unusable", { path: customStoragePath }))
45 }
46 return defaultPath
47 }
48}
49
50/**
51 * Gets the storage directory path for a task

Callers 6

getTasksDirMethod · 0.90
getTaskDirectoryPathFunction · 0.85
getSettingsDirectoryPathFunction · 0.85
getCacheDirectoryPathFunction · 0.85
storage.spec.tsFile · 0.85

Calls 7

tFunction · 0.90
StringInterface · 0.70
getConfigurationMethod · 0.65
getMethod · 0.65
warnMethod · 0.65
errorMethod · 0.65
showErrorMessageMethod · 0.45

Tested by

no test coverage detected