fix: skip writing symlinks before postUpgradeTasks execution (#24389)

This commit is contained in:
Yun Lai 2023-09-13 14:36:56 +10:00 committed by GitHub
parent 99b393ba29
commit ab17060aea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View file

@ -26,6 +26,12 @@ describe('workers/repository/update/branch/execute-post-upgrade-commands', () =>
updatedArtifacts: [
{ type: 'addition', path: 'some-existing-dir', contents: '' },
{ type: 'addition', path: 'artifact', contents: '' },
{
type: 'addition',
path: 'symlink',
contents: 'dest',
isSymlink: true,
},
],
artifactErrors: [],
upgrades: [],
@ -45,8 +51,10 @@ describe('workers/repository/update/branch/execute-post-upgrade-commands', () =>
});
fs.localPathIsFile
.mockResolvedValueOnce(true)
.mockResolvedValueOnce(false);
.mockResolvedValueOnce(false)
.mockResolvedValueOnce(true);
fs.localPathExists
.mockResolvedValueOnce(true)
.mockResolvedValueOnce(true)
.mockResolvedValueOnce(true);
@ -55,7 +63,7 @@ describe('workers/repository/update/branch/execute-post-upgrade-commands', () =>
config
);
expect(res.updatedArtifacts).toHaveLength(2);
expect(res.updatedArtifacts).toHaveLength(3);
expect(fs.writeLocalFile).toHaveBeenCalledTimes(1);
});
});

View file

@ -51,7 +51,7 @@ export async function postUpgradeCommandsExecutor(
// Persist updated files in file system so any executed commands can see them
for (const file of config.updatedPackageFiles!.concat(updatedArtifacts)) {
const canWriteFile = await localPathIsFile(file.path);
if (file.type === 'addition' && canWriteFile) {
if (file.type === 'addition' && !file.isSymlink && canWriteFile) {
let contents: Buffer | null;
if (typeof file.contents === 'string') {
contents = Buffer.from(file.contents);