respect the umask argument in dumpFile()

This commit is contained in:
Christian Flothmann 2017-03-06 19:56:39 +01:00
parent c91db73fbb
commit 3a7cd08fe7
2 changed files with 15 additions and 2 deletions

View File

@ -516,8 +516,8 @@ class Filesystem
}
$this->chmod($tmpFile, $mode);
} else {
@chmod($tmpFile, file_exists($filename) ? fileperms($filename) : 0666 & ~umask());
} elseif (file_exists($filename)) {
@chmod($tmpFile, fileperms($filename));
}
$this->rename($tmpFile, $filename, true);

View File

@ -1050,6 +1050,19 @@ class FilesystemTest extends FilesystemTestCase
$this->assertSame('bar', file_get_contents($filename));
}
public function testDumpKeepsExistingPermissionsWhenOverwritingAnExistingFile()
{
$this->markAsSkippedIfChmodIsMissing();
$filename = $this->workspace.DIRECTORY_SEPARATOR.'foo.txt';
file_put_contents($filename, 'FOO BAR');
chmod($filename, 0745);
$this->filesystem->dumpFile($filename, 'bar', null);
$this->assertFilePermissions(745, $filename);
}
public function testCopyShouldKeepExecutionPermission()
{
$this->markAsSkippedIfChmodIsMissing();