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 56fa4dc

Browse filesBrowse files
bug #58185 [Filesystem] make sure temp files can be cleaned up on Windows (xabbuh)
This PR was merged into the 5.4 branch. Discussion ---------- [Filesystem] make sure temp files can be cleaned up on Windows | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | | License | MIT based on the findings while debugging the AppVeyor failures that we worked around in #58152 Commits ------- a832b67 make sure temp files can be cleaned up on Windows
2 parents fb69394 + a832b67 commit 56fa4dc
Copy full SHA for 56fa4dc

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
@@ -702,6 +702,10 @@ public function dumpFile(string $filename, $content)
702702
$this->rename($tmpFile, $filename, true);
703703
} finally {
704704
if (file_exists($tmpFile)) {
705+
if ('\\' === \DIRECTORY_SEPARATOR && !is_writable($tmpFile)) {
706+
self::box('chmod', $tmpFile, self::box('fileperms', $tmpFile) | 0200);
707+
}
708+
705709
self::box('unlink', $tmpFile);
706710
}
707711
}

‎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.