Skip to content

Commit 06a37e8

Browse files
committed
Don't remove already existing file when doing partitioning
1 parent 9375b1b commit 06a37e8

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

src/core/etl/src/Flow/ETL/Filesystem/FilesystemStreams.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function closeStreams(Path $path) : void
4141

4242
if ($this->saveMode === SaveMode::Overwrite) {
4343
if ($fileStream->path()->partitions()->count()) {
44-
$partitionFilesPatter = \Flow\Filesystem\DSL\path($fileStream->path()->parentDirectory()->uri() . '/*', $fileStream->path()->options());
44+
$partitionFilesPatter = Path::from($fileStream->path()->parentDirectory()->uri() . '/' . $fileStream->path()->basename(), $fileStream->path()->options());
4545

4646
foreach ($fs->list($partitionFilesPatter) as $partitionFile) {
4747
if (\str_contains($partitionFile->path->path(), self::FLOW_TMP_FILE_PREFIX)) {
@@ -54,7 +54,7 @@ public function closeStreams(Path $path) : void
5454

5555
$fs->mv(
5656
$fileStream->path(),
57-
\Flow\Filesystem\DSL\path(
57+
Path::from(
5858
\str_replace(self::FLOW_TMP_FILE_PREFIX, '', $fileStream->path()->uri()),
5959
$fileStream->path()->options()
6060
)

src/core/etl/tests/Flow/ETL/Tests/Integration/Filesystem/FilesystemStreams/Partitioned/OverwriteModeTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function test_open_stream_for_existing_partition_with_existing_file() : v
2727
$this->setupFiles([
2828
__FUNCTION__ => [
2929
'partition=value' => [
30+
'existing.txt' => 'file content',
3031
'file.txt' => 'file content',
3132
],
3233
],
@@ -39,10 +40,10 @@ public function test_open_stream_for_existing_partition_with_existing_file() : v
3940

4041
$files = \iterator_to_array($this->fs()->list(path($file->parentDirectory()->path() . '/**/*.txt')));
4142

42-
self::assertCount(1, $files);
43+
self::assertCount(2, $files);
4344

44-
self::assertStringStartsWith('file.txt', $files[0]->path->basename());
45-
self::assertSame('new content', \file_get_contents($files[0]->path->path()));
45+
self::assertStringStartsWith('file.txt', $files[1]->path->basename());
46+
self::assertSame('new content', \file_get_contents($files[1]->path->path()));
4647
}
4748

4849
public function test_open_stream_for_existing_partition_without_existing_file() : void

0 commit comments

Comments
 (0)