MCPcopy
hub / github.com/upstash/context7 / migrateLegacyFileSync

Function migrateLegacyFileSync

packages/cli/src/utils/storage-paths.ts:57–72  ·  view source on GitHub ↗
(fileName: string, targetPath: string, mode?: number)

Source from the content-addressed store, hash-verified

55 * callers fall back to reading the legacy file rather than crashing.
56 */
57export function migrateLegacyFileSync(fileName: string, targetPath: string, mode?: number): void {
58 const legacyPath = getLegacyFilePath(fileName);
59 if (legacyPath === targetPath || fs.existsSync(targetPath) || !fs.existsSync(legacyPath)) {
60 return;
61 }
62
63 try {
64 fs.mkdirSync(path.dirname(targetPath), { recursive: true, mode: 0o700 });
65 fs.renameSync(legacyPath, targetPath);
66 if (mode !== undefined) {
67 fs.chmodSync(targetPath, mode);
68 }
69 } catch {
70 // Leave the legacy file in place; readers resolve to it via resolveReadPathSync.
71 }
72}
73
74export async function migrateLegacyFile(
75 fileName: string,

Callers 2

resolveReadPathSyncFunction · 0.85
saveTokensFunction · 0.85

Calls 1

getLegacyFilePathFunction · 0.85

Tested by

no test coverage detected