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

Appearance settings

Commit a832b67

Browse filesBrowse files
committed
make sure temp files can be cleaned up on Windows
1 parent 6896976 commit a832b67
Copy full SHA for a832b67

File tree

2 files changed

+20
-0
lines changed
Filter options

2 files changed

+20
-0
lines changed

‎src/Symfony/Component/Filesystem/Filesystem.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Filesystem/Filesystem.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,10 @@ public function dumpFile(string $filename, $content)
696696
$this->rename($tmpFile, $filename, true);
697697
} finally {
698698
if (file_exists($tmpFile)) {
699+
if ('\\' === \DIRECTORY_SEPARATOR && !is_writable($tmpFile)) {
700+
self::box('chmod', $tmpFile, self::box('fileperms', $tmpFile) | 0200);
701+
}
702+
699703
self::box('unlink', $tmpFile);
700704
}
701705
}

‎src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,6 +1826,22 @@ public function testDumpKeepsExistingPermissionsWhenOverwritingAnExistingFile()
18261826
$this->assertFilePermissions(745, $filename);
18271827
}
18281828

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+
18291845
public function testCopyShouldKeepExecutionPermission()
18301846
{
18311847
$this->markAsSkippedIfChmodIsMissing();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.