Skip to content

Commit c24c1cd

Browse files
committed
Added new tmp folder at root
`tmp` is a new folder that serves as container for temporary files. It is very similar to `cache` but its content is meant to be more persistent than cache. Temporary files are meant to survive cache clearance, developers should be responsible of ensuring temporary files are properly removed when needed. Accessible via stream `tmp://`. Can be cleared with `bin/grav clear --tmp-only` as well as `--all`.
1 parent 7d7ef5e commit c24c1cd

File tree

8 files changed

+30
-17
lines changed

8 files changed

+30
-17
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# v1.1.4
2+
## XX/XX/2016
3+
4+
1. [](#new)
5+
* Added new `tmp` folder at root. Accessible via stream `tmp://`. Can be cleared with `bin/grav clear --tmp-only` as well as `--all`.
6+
17
# v1.1.3
28
## 08/14/2016
39

system/src/Grav/Common/Backup/ZipBackup.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ class ZipBackup
1717
'backup',
1818
'cache',
1919
'images',
20-
'logs'
20+
'logs',
21+
'tmp'
2122
];
2223

2324
protected static $ignoreFolders = [

system/src/Grav/Common/Cache.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ class Cache extends Getters
6565
protected static $all_remove = [
6666
'cache://',
6767
'cache://images',
68-
'asset://'
68+
'asset://',
69+
'tmp://'
6970
];
7071

7172
protected static $assets_remove = [
@@ -80,6 +81,10 @@ class Cache extends Getters
8081
'cache://'
8182
];
8283

84+
protected static $tmp_remove = [
85+
'tmp://'
86+
];
87+
8388
/**
8489
* Constructor
8590
*
@@ -309,6 +314,9 @@ public static function clearCache($remove = 'standard')
309314
case 'cache-only':
310315
$remove_paths = self::$cache_remove;
311316
break;
317+
case 'tmp-only':
318+
$remove_paths = self::$tmp_remove;
319+
break;
312320
default:
313321
$remove_paths = self::$standard_remove;
314322
}

system/src/Grav/Common/Config/Setup.php

+6
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ class Setup extends Data
9595
'' => ['backup']
9696
]
9797
],
98+
'tmp' => [
99+
'type' => 'Stream',
100+
'prefixes' => [
101+
'' => ['tmp']
102+
]
103+
],
98104
'image' => [
99105
'type' => 'ReadOnlyStream',
100106
'prefixes' => [

system/src/Grav/Common/Data/Validation.php

-12
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ public static function validate($value, array $field)
3737
$field['type'] = 'text';
3838
}
3939

40-
// Special case for files, value is never empty and errors with code 4 instead.
41-
if (empty($validate['required']) && $field['type'] == 'file' && isset($value['error'])
42-
&& ($value['error'] == UPLOAD_ERR_NO_FILE || in_array(UPLOAD_ERR_NO_FILE, $value['error']))) {
43-
return $messages;
44-
}
45-
4640
// Get language class.
4741
$language = Grav::instance()['language'];
4842

@@ -101,12 +95,6 @@ public static function filter($value, array $field)
10195
$field['type'] = 'text';
10296
}
10397

104-
// Special case for files, value is never empty and errors with code 4 instead.
105-
if (empty($validate['required']) && $field['type'] == 'file' && isset($value['error'])
106-
&& ($value['error'] == UPLOAD_ERR_NO_FILE || in_array(UPLOAD_ERR_NO_FILE, $value['error']))) {
107-
return null;
108-
}
109-
11098
// If this is a YAML field, simply parse it and return the value.
11199
if (isset($field['yaml']) && $field['yaml'] === true) {
112100
try {

system/src/Grav/Console/Cli/ClearCacheCommand.php

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ protected function configure()
2727
->addOption('assets-only', null, InputOption::VALUE_NONE, 'If set will remove only assets/*')
2828
->addOption('images-only', null, InputOption::VALUE_NONE, 'If set will remove only images/*')
2929
->addOption('cache-only', null, InputOption::VALUE_NONE, 'If set will remove only cache/*')
30+
->addOption('tmp-only', null, InputOption::VALUE_NONE, 'If set will remove only tmp/*')
3031
->setHelp('The <info>clear-cache</info> deletes all cache files');
3132
}
3233

@@ -55,6 +56,8 @@ private function cleanPaths()
5556
$remove = 'images-only';
5657
} elseif ($this->input->getOption('cache-only')) {
5758
$remove = 'cache-only';
59+
} elseif ($this->input->getOption('tmp-only')) {
60+
$remove = 'tmp-only';
5861
} else {
5962
$remove = 'standard';
6063
}

system/src/Grav/Console/Cli/SandboxCommand.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@ class SandboxCommand extends ConsoleCommand
1919
* @var array
2020
*/
2121
protected $directories = [
22+
'/assets',
2223
'/backup',
2324
'/cache',
24-
'/logs',
2525
'/images',
26-
'/assets',
26+
'/logs',
27+
'/tmp',
2728
'/user/accounts',
2829
'/user/config',
29-
'/user/pages',
3030
'/user/data',
31+
'/user/pages',
3132
'/user/plugins',
3233
'/user/themes',
3334
];

tmp/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)