Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: temporary typo #15329

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 11 additions & 11 deletions packages/vite/src/node/optimizer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ export function runOptimizeDeps(
const depsCacheDir = getDepsCacheDir(resolvedConfig, ssr)
const processingCacheDir = getProcessingDepsCacheDir(resolvedConfig, ssr)

// Create a temporal directory so we don't need to delete optimized deps
// Create a temporary directory so we don't need to delete optimized deps
// until they have been processed. This also avoids leaving the deps cache
// directory in a corrupted state if there is an error
fs.mkdirSync(processingCacheDir, { recursive: true })
Expand Down Expand Up @@ -517,7 +517,7 @@ export function runOptimizeDeps(
committed = true

// Write metadata file, then commit the processing folder to the global deps cache
// Rewire the file paths from the temporal processing dir to the final deps cache dir
// Rewire the file paths from the temporary processing dir to the final deps cache dir
const dataPath = path.join(processingCacheDir, '_metadata.json')
debug?.(colors.green(`creating _metadata.json in ${processingCacheDir}`))
fs.writeFileSync(
Expand All @@ -526,39 +526,39 @@ export function runOptimizeDeps(
)

// In order to minimize the time where the deps folder isn't in a consistent state,
// we first rename the old depsCacheDir to a temporal path, then we rename the
// we first rename the old depsCacheDir to a temporary path, then we rename the
// new processing cache dir to the depsCacheDir. In systems where doing so in sync
// is safe, we do an atomic operation (at least for this thread). For Windows, we
// found there are cases where the rename operation may finish before it's done
// so we do a graceful rename checking that the folder has been properly renamed.
// We found that the rename-rename (then delete the old folder in the background)
// is safer than a delete-rename operation.
const temporalPath = depsCacheDir + getTempSuffix()
const temporaryPath = depsCacheDir + getTempSuffix()
const depsCacheDirPresent = fs.existsSync(depsCacheDir)
if (isWindows) {
if (depsCacheDirPresent) {
debug?.(colors.green(`renaming ${depsCacheDir} to ${temporalPath}`))
await safeRename(depsCacheDir, temporalPath)
debug?.(colors.green(`renaming ${depsCacheDir} to ${temporaryPath}`))
await safeRename(depsCacheDir, temporaryPath)
}
debug?.(
colors.green(`renaming ${processingCacheDir} to ${depsCacheDir}`),
)
await safeRename(processingCacheDir, depsCacheDir)
} else {
if (depsCacheDirPresent) {
debug?.(colors.green(`renaming ${depsCacheDir} to ${temporalPath}`))
fs.renameSync(depsCacheDir, temporalPath)
debug?.(colors.green(`renaming ${depsCacheDir} to ${temporaryPath}`))
fs.renameSync(depsCacheDir, temporaryPath)
}
debug?.(
colors.green(`renaming ${processingCacheDir} to ${depsCacheDir}`),
)
fs.renameSync(processingCacheDir, depsCacheDir)
}

// Delete temporal path in the background
// Delete temporary path in the background
if (depsCacheDirPresent) {
debug?.(colors.green(`removing cache temp dir ${temporalPath}`))
fsp.rm(temporalPath, { recursive: true, force: true })
debug?.(colors.green(`removing cache temp dir ${temporaryPath}`))
fsp.rm(temporaryPath, { recursive: true, force: true })
}
},
}
Expand Down