Skip to content

Commit

Permalink
Merge branch '6.4' into 7.1
Browse files Browse the repository at this point in the history
* 6.4:
  [Serializer] Fix for method named `get()`
  [Notifier][TurboSMS] Process partial accepted response from transport
  [HttpClient] Fix setting CURLMOPT_MAXCONNECTS
  throw a meaningful exception when parsing dotenv files with BOM
  [FrameworkBundle] Fix schema & finish incomplete tests for lock & semaphore config
  [Cache] Fix RedisSentinel params types
  [FrameworkBundle] Fix service reset between tests
  [Uid][Serializer][Validator] Mention RFC 9562
  make sure temp files can be cleaned up on Windows
  • Loading branch information
xabbuh committed Sep 17, 2024
2 parents a9da7a3 + f810e3c commit 61fe056
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,10 @@ public function dumpFile(string $filename, $content): void
$this->rename($tmpFile, $filename, true);
} finally {
if (file_exists($tmpFile)) {
if ('\\' === \DIRECTORY_SEPARATOR && !is_writable($tmpFile)) {
self::box('chmod', $tmpFile, self::box('fileperms', $tmpFile) | 0200);
}

self::box('unlink', $tmpFile);
}
}
Expand Down
16 changes: 16 additions & 0 deletions Tests/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1813,6 +1813,22 @@ public function testDumpKeepsExistingPermissionsWhenOverwritingAnExistingFile()
$this->assertFilePermissions(745, $filename);
}

public function testDumpFileCleansUpAfterFailure()
{
$targetFile = $this->workspace.'/dump-file';
$this->filesystem->touch($targetFile);
$this->filesystem->chmod($targetFile, 0444);

try {
$this->filesystem->dumpFile($targetFile, 'any content');
} catch (IOException $e) {
} finally {
$this->filesystem->chmod($targetFile, 0666);
}

$this->assertSame([$targetFile], glob($this->workspace.'/*'));
}

public function testReadFile()
{
$licenseFile = \dirname(__DIR__).'/LICENSE';
Expand Down

0 comments on commit 61fe056

Please sign in to comment.