Skip to content

Commit

Permalink
Fix chunk symlinks to ensure overwriting old links (#3868)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwest1066 committed Feb 25, 2021
1 parent 7df2245 commit 2303938
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/chunks.js
Expand Up @@ -701,7 +701,15 @@ const ensureChunk = async (courseId, chunk) => {
});

// Finally, link targetPath -> relativeUnpackPath
await fs.ensureSymlink(relativeUnpackPath, targetPath);
// Note that ensureSymlink() won't overwrite an existing targetPath
// See:
// https://github.com/jprichardson/node-fs-extra/pull/869
// https://github.com/jprichardson/node-fs-extra/issues/786
// https://github.com/jprichardson/node-fs-extra/pull/826
// As a work-around, we symlink a temporary name and move it over targetPath
const tmpPath = `${targetPath}-${chunk.uuid}`;
await fs.ensureSymlink(relativeUnpackPath, tmpPath);
await fs.rename(tmpPath, targetPath);
};

/** @type {Map<string, Promise>} */
Expand Down

0 comments on commit 2303938

Please sign in to comment.