mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Adds error message to blog import on empty / bad file
Closes #840 * Checks file to be size > 0 * Checks file to be .json * Fails if either of them are not good
This commit is contained in:
parent
6bd62538af
commit
f709dcb798
1 changed files with 10 additions and 3 deletions
|
@ -317,11 +317,18 @@ adminControllers = {
|
|||
});
|
||||
},
|
||||
'import': function (req, res) {
|
||||
if (!req.files.importfile) {
|
||||
// Notify of an error if it occurs
|
||||
if (!req.files.importfile || req.files.importfile.size === 0 || req.files.importfile.name.indexOf('json') === -1) {
|
||||
/**
|
||||
* Notify of an error if it occurs
|
||||
*
|
||||
* - If there's no file (although if you don't select anything, the input is still submitted, so
|
||||
* !req.files.importfile will always be false)
|
||||
* - If the size is 0
|
||||
* - If the name doesn't have json in it
|
||||
*/
|
||||
var notification = {
|
||||
type: 'error',
|
||||
message: "Must select a file to import",
|
||||
message: "Must select a .json file to import",
|
||||
status: 'persistent',
|
||||
id: 'per-' + (ghost.notifications.length + 1)
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue