Skip to content

Commit 542ba3b

Browse files
#18 Add ignore_missing option on FileFetchTask that allow throwing Exception when file(s) not found.
1 parent af40e70 commit 542ba3b

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

Diff for: docs/reference/tasks/01-FileFetchTask.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ Filename of copied file.
2727
Options
2828
-------
2929

30-
| Code | Type | Required | Default | Description |
31-
|--------------------------|:----------:|:---------:|:---------:|----------------------------------------------------------------------------------------------------------------------------------------------|
32-
| `source_filesystem` | `string` | **X** | | The source flysystem/storage.<br/>See config/packages/flysystem.yaml to see configured flysystem/storages. |
33-
| `destination_filesystem` | `string` | **X** | | The source flysystem/storage.<br/>See config/packages/flysystem.yaml to see configured flysystem/storages. |
34-
| `file_pattern` | `string` | | null | The file_pattern used in preg_match to match into `source_filesystem` list of files. If not set try to use input as strict filename to match |
35-
| `remove_source` | `bool` | | false | If true delete source file after copy |
30+
| Code | Type | Required | Default | Description |
31+
|--------------------------|:--------:|:--------:|:-------:|----------------------------------------------------------------------------------------------------------------------------------------------|
32+
| `source_filesystem` | `string` | **X** | | The source flysystem/storage.<br/>See config/packages/flysystem.yaml to see configured flysystem/storages. |
33+
| `destination_filesystem` | `string` | **X** | | The source flysystem/storage.<br/>See config/packages/flysystem.yaml to see configured flysystem/storages. |
34+
| `file_pattern` | `string` | | null | The file_pattern used in preg_match to match into `source_filesystem` list of files. If not set try to use input as strict filename to match |
35+
| `remove_source` | `bool` | | false | If true delete source file after copy |
36+
| `ignore_missing` | `bool` | | true | Ignore property accessor errors for this source |
3637

3738

3839
Examples
@@ -43,6 +44,7 @@ Examples
4344
- copy all .csv files from 'storage.source' to 'storage.destination'
4445
- remove .csv from 'storage.source' after copy
4546
- output will be filename of copied files
47+
- throw Exception when file(s) not found
4648
```yaml
4749
# Task configuration level
4850
code:
@@ -52,6 +54,7 @@ code:
5254
destination_filesystem: 'storage.destination'
5355
file_pattern: '/.csv$/'
5456
remove_source: true
57+
ignore_missing: false
5558
```
5659
5760
* Simple fetch process configuration to cipy a specific file from --input option via <br> ```bin/console cleverage:process:execute my_custom_process --input=foobar.csv -vv```

Diff for: src/Task/FileFetchTask.php

+6
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ protected function findMatchingFiles(ProcessState $state): void
127127
$this->matchingFiles[] = $input;
128128
}
129129
}
130+
if ([] === $this->matchingFiles && !$this->getOption($state, 'ignore_missing')) {
131+
throw new \UnexpectedValueException('File(s) not found in source filesystem');
132+
}
130133
}
131134

132135
/**
@@ -166,5 +169,8 @@ protected function configureOptions(OptionsResolver $resolver): void
166169

167170
$resolver->setDefault('remove_source', false);
168171
$resolver->setAllowedTypes('remove_source', 'boolean');
172+
173+
$resolver->setDefault('ignore_missing', true);
174+
$resolver->setAllowedTypes('ignore_missing', 'boolean');
169175
}
170176
}

0 commit comments

Comments
 (0)