mirror of
https://github.com/getgrav/grav.git
synced 2025-12-05 15:29:57 +01:00
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`.
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
# v1.1.4
|
||||
## XX/XX/2016
|
||||
|
||||
1. [](#new)
|
||||
* Added new `tmp` folder at root. Accessible via stream `tmp://`. Can be cleared with `bin/grav clear --tmp-only` as well as `--all`.
|
||||
|
||||
# v1.1.3
|
||||
## 08/14/2016
|
||||
|
||||
|
||||
@@ -17,7 +17,8 @@ class ZipBackup
|
||||
'backup',
|
||||
'cache',
|
||||
'images',
|
||||
'logs'
|
||||
'logs',
|
||||
'tmp'
|
||||
];
|
||||
|
||||
protected static $ignoreFolders = [
|
||||
|
||||
@@ -65,7 +65,8 @@ class Cache extends Getters
|
||||
protected static $all_remove = [
|
||||
'cache://',
|
||||
'cache://images',
|
||||
'asset://'
|
||||
'asset://',
|
||||
'tmp://'
|
||||
];
|
||||
|
||||
protected static $assets_remove = [
|
||||
@@ -80,6 +81,10 @@ class Cache extends Getters
|
||||
'cache://'
|
||||
];
|
||||
|
||||
protected static $tmp_remove = [
|
||||
'tmp://'
|
||||
];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -309,6 +314,9 @@ class Cache extends Getters
|
||||
case 'cache-only':
|
||||
$remove_paths = self::$cache_remove;
|
||||
break;
|
||||
case 'tmp-only':
|
||||
$remove_paths = self::$tmp_remove;
|
||||
break;
|
||||
default:
|
||||
$remove_paths = self::$standard_remove;
|
||||
}
|
||||
|
||||
@@ -95,6 +95,12 @@ class Setup extends Data
|
||||
'' => ['backup']
|
||||
]
|
||||
],
|
||||
'tmp' => [
|
||||
'type' => 'Stream',
|
||||
'prefixes' => [
|
||||
'' => ['tmp']
|
||||
]
|
||||
],
|
||||
'image' => [
|
||||
'type' => 'ReadOnlyStream',
|
||||
'prefixes' => [
|
||||
|
||||
@@ -37,12 +37,6 @@ class Validation
|
||||
$field['type'] = 'text';
|
||||
}
|
||||
|
||||
// Special case for files, value is never empty and errors with code 4 instead.
|
||||
if (empty($validate['required']) && $field['type'] == 'file' && isset($value['error'])
|
||||
&& ($value['error'] == UPLOAD_ERR_NO_FILE || in_array(UPLOAD_ERR_NO_FILE, $value['error']))) {
|
||||
return $messages;
|
||||
}
|
||||
|
||||
// Get language class.
|
||||
$language = Grav::instance()['language'];
|
||||
|
||||
@@ -101,12 +95,6 @@ class Validation
|
||||
$field['type'] = 'text';
|
||||
}
|
||||
|
||||
// Special case for files, value is never empty and errors with code 4 instead.
|
||||
if (empty($validate['required']) && $field['type'] == 'file' && isset($value['error'])
|
||||
&& ($value['error'] == UPLOAD_ERR_NO_FILE || in_array(UPLOAD_ERR_NO_FILE, $value['error']))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// If this is a YAML field, simply parse it and return the value.
|
||||
if (isset($field['yaml']) && $field['yaml'] === true) {
|
||||
try {
|
||||
|
||||
@@ -27,6 +27,7 @@ class ClearCacheCommand extends ConsoleCommand
|
||||
->addOption('assets-only', null, InputOption::VALUE_NONE, 'If set will remove only assets/*')
|
||||
->addOption('images-only', null, InputOption::VALUE_NONE, 'If set will remove only images/*')
|
||||
->addOption('cache-only', null, InputOption::VALUE_NONE, 'If set will remove only cache/*')
|
||||
->addOption('tmp-only', null, InputOption::VALUE_NONE, 'If set will remove only tmp/*')
|
||||
->setHelp('The <info>clear-cache</info> deletes all cache files');
|
||||
}
|
||||
|
||||
@@ -55,6 +56,8 @@ class ClearCacheCommand extends ConsoleCommand
|
||||
$remove = 'images-only';
|
||||
} elseif ($this->input->getOption('cache-only')) {
|
||||
$remove = 'cache-only';
|
||||
} elseif ($this->input->getOption('tmp-only')) {
|
||||
$remove = 'tmp-only';
|
||||
} else {
|
||||
$remove = 'standard';
|
||||
}
|
||||
|
||||
@@ -19,15 +19,16 @@ class SandboxCommand extends ConsoleCommand
|
||||
* @var array
|
||||
*/
|
||||
protected $directories = [
|
||||
'/assets',
|
||||
'/backup',
|
||||
'/cache',
|
||||
'/logs',
|
||||
'/images',
|
||||
'/assets',
|
||||
'/logs',
|
||||
'/tmp',
|
||||
'/user/accounts',
|
||||
'/user/config',
|
||||
'/user/pages',
|
||||
'/user/data',
|
||||
'/user/pages',
|
||||
'/user/plugins',
|
||||
'/user/themes',
|
||||
];
|
||||
|
||||
0
tmp/.gitkeep
Normal file
0
tmp/.gitkeep
Normal file
Reference in New Issue
Block a user