Skip to content

Commit

Permalink
Add missing comment and improve clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime Bargiel committed Jun 1, 2019
1 parent 1a6eacb commit 4828641
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/copy-sync/copy-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ function copyFileFallback (srcStat, src, dest, opts) {

function setDestTimestampsAndMode (srcStat, src, dest, opts) {
if ((srcStat.mode & 0o200) === 0) {
// Make sure the file is writable before setting the timestamp
// otherwise openSync below fails with EPERM when invoked with 'r+'
fs.chmodSync(dest, srcStat.mode | 0o200)
}
const fdw = fs.openSync(dest, 'r+')
Expand Down
3 changes: 2 additions & 1 deletion lib/copy/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ function copyFile (srcStat, src, dest, opts, cb) {
if (err) return cb(err)
if ((srcStat.mode & 0o200) === 0) {
// Make sure the file is writable before setting the timestamp
// otherwise utimes fails with EPERM
// otherwise openSync fails with EPERM when invoked with 'r+'
// (through utimes call)
return fs.chmod(dest, srcStat.mode | 0o200,
err => {
if (err) return cb(err)
Expand Down

0 comments on commit 4828641

Please sign in to comment.