Consider the umask setting when dumping a file.

This commit is contained in:
Leo Feyer 2016-09-06 15:46:21 +02:00
parent be4255e5bc
commit fdd266f28e
2 changed files with 8 additions and 3 deletions

View File

@ -554,8 +554,7 @@ class Filesystem
throw new IOException(sprintf('Failed to write file "%s".', $filename), 0, null, $filename);
}
// Ignore for filesystems that do not support umask
@chmod($tmpFile, 0666);
@chmod($tmpFile, 0666 & ~umask());
$this->rename($tmpFile, $filename, true);
}

View File

@ -1101,13 +1101,19 @@ class FilesystemTest extends FilesystemTestCase
{
$filename = $this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'baz.txt';
// skip mode check on Windows
if ('\\' !== DIRECTORY_SEPARATOR) {
$oldMask = umask(0002);
}
$this->filesystem->dumpFile($filename, 'bar');
$this->assertFileExists($filename);
$this->assertSame('bar', file_get_contents($filename));
// skip mode check on Windows
if ('\\' !== DIRECTORY_SEPARATOR) {
$this->assertFilePermissions(666, $filename);
$this->assertFilePermissions(664, $filename);
umask($oldMask);
}
}