File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Filter options
Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Original file line number Diff line number Diff line change @@ -696,6 +696,10 @@ public function dumpFile(string $filename, $content)
696
696
$ this ->rename ($ tmpFile , $ filename , true );
697
697
} finally {
698
698
if (file_exists ($ tmpFile )) {
699
+ if ('\\' === \DIRECTORY_SEPARATOR && !is_writable ($ tmpFile )) {
700
+ self ::box ('chmod ' , $ tmpFile , self ::box ('fileperms ' , $ tmpFile ) | 0200 );
701
+ }
702
+
699
703
self ::box ('unlink ' , $ tmpFile );
700
704
}
701
705
}
Original file line number Diff line number Diff line change @@ -1826,6 +1826,22 @@ public function testDumpKeepsExistingPermissionsWhenOverwritingAnExistingFile()
1826
1826
$ this ->assertFilePermissions (745 , $ filename );
1827
1827
}
1828
1828
1829
+ public function testDumpFileCleansUpAfterFailure ()
1830
+ {
1831
+ $ targetFile = $ this ->workspace .'/dump-file ' ;
1832
+ $ this ->filesystem ->touch ($ targetFile );
1833
+ $ this ->filesystem ->chmod ($ targetFile , 0444 );
1834
+
1835
+ try {
1836
+ $ this ->filesystem ->dumpFile ($ targetFile , 'any content ' );
1837
+ } catch (IOException $ e ) {
1838
+ } finally {
1839
+ $ this ->filesystem ->chmod ($ targetFile , 0666 );
1840
+ }
1841
+
1842
+ $ this ->assertSame ([$ targetFile ], glob ($ this ->workspace .'/* ' ));
1843
+ }
1844
+
1829
1845
public function testCopyShouldKeepExecutionPermission ()
1830
1846
{
1831
1847
$ this ->markAsSkippedIfChmodIsMissing ();
You can’t perform that action at this time.
0 commit comments