Skip to content

Commit

Permalink
Temporarily wrap files.rename on non-Windows platforms to validate sa…
Browse files Browse the repository at this point in the history
…fety.

Now that files.rename uses Promise.prototype.await on Windows, it's
important to be sure it never gets called outside of a Fiber. Though we
don't run our full test suite on Windows, we can validate this expectation
by wrapping files.rename on all platforms. This commit should be reverted
once the validation is complete.
  • Loading branch information
benjamn committed Nov 12, 2019
1 parent d52c9cc commit 52d4809
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions tools/fs/files.ts
Expand Up @@ -35,7 +35,6 @@ import {
convertToStandardLineEndings,
convertToStandardPath,
convertToWindowsPath,
isWindowsLikeFilesystem,
pathBasename,
pathDirname,
pathJoin,
Expand Down Expand Up @@ -1691,7 +1690,7 @@ export function copyFile(from: string, to: string, flags = 0) {
}

const wrappedRename = wrapDestructiveFsFunc("rename", fs.renameSync, [0, 1]);
export const rename = isWindowsLikeFilesystem() ? function (from: string, to: string) {
export function rename(from: string, to: string) {
// Retries are necessary only on Windows, because the rename call can
// fail with EBUSY, which means the file is in use.
const osTo = convertToOSPath(to);
Expand Down Expand Up @@ -1728,7 +1727,7 @@ export const rename = isWindowsLikeFilesystem() ? function (from: string, to: st
throw error;
}
}).await();
} : wrappedRename;
}

// Warning: doesn't convert slashes in the second 'cache' arg
export const realpath =
Expand Down

0 comments on commit 52d4809

Please sign in to comment.