Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit572d79b

Browse files
authored
Merge pull request#1745 from gruntjs/fix-copy-op
Patch up race condition in symlink copying.
2 parents0749e1d +58016ff commit572d79b

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

‎CHANGELOG‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
v1.5.3
2+
date: 2022-04-23
3+
changes:
4+
- Patch up race condition in symlink copying.
15
v1.5.2
26
date: 2022-04-12
37
changes:

‎lib/grunt/file.js‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,6 @@ file.write = function(filepath, contents, options) {
294294
// processing content, writing output.
295295
// Handles symlinks by coping them as files or directories.
296296
file.copy=functioncopy(srcpath,destpath,options){
297-
if(file.isLink(destpath)){
298-
// in case destpath is a symlink, avoid following the symlink, instead overwrite it later
299-
fs.unlinkSync(destpath);
300-
}
301-
302297
if(file.isLink(srcpath)){
303298
file._copySymbolicLink(srcpath,destpath);
304299
}elseif(file.isDir(srcpath)){
@@ -338,8 +333,8 @@ file._copy = function(srcpath, destpath, options) {
338333
}
339334
}
340335
// Abort copy if the process function returns false.
341-
if(contents===false){
342-
grunt.verbose.writeln('Write aborted.');
336+
if(contents===false||file.isLink(destpath)){
337+
grunt.verbose.writeln('Write aborted. Either the process function returned false or the destination is a symlink');
343338
}else{
344339
file.write(destpath,contents,readWriteOptions);
345340
}

‎test/grunt/file_test.js‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,5 +916,13 @@ exports.file = {
916916
test.ok(fs.lstatSync(path.join(destdir.path,path.basename(fixtures))).isSymbolicLink());
917917
test.done();
918918
},
919-
}
919+
},
920+
'symbolicLinkDestError':function(test){
921+
test.expect(1);
922+
vartmpfile=newTempdir();
923+
fs.symlinkSync(path.resolve('test/fixtures/octocat.png'),path.join(tmpfile.path,'octocat.png'),'file');
924+
grunt.file.copy(path.resolve('test/fixtures/octocat.png'),path.join(tmpfile.path,'octocat.png'));
925+
test.ok(fs.lstatSync(path.join(tmpfile.path,'octocat.png')).isSymbolicLink());
926+
test.done();
927+
},
920928
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp