| 25 | } |
| 26 | |
| 27 | @Override |
| 28 | protected boolean run() { |
| 29 | final String pattern = args[0]; |
| 30 | final boolean general = pattern.isEmpty(); |
| 31 | if(!(general || Databases.validPattern(pattern))) return error(NAME_INVALID_X, pattern); |
| 32 | |
| 33 | // loop through all databases and collect databases to be dropped |
| 34 | final Databases db = context.databases; |
| 35 | final User user = context.user(); |
| 36 | final StringList names = general ? new StringList("") : db.list(user, pattern); |
| 37 | // if the given argument is not a database name, it could be the name of a backup file |
| 38 | if(names.isEmpty() && user.has(Perm.READ, pattern)) names.add(pattern); |
| 39 | |
| 40 | // drop all backups |
| 41 | for(final String name : names) { |
| 42 | for(final String backup : db.backups(name)) { |
| 43 | drop(backup, soptions); |
| 44 | } |
| 45 | } |
| 46 | return info(BACKUP_DROPPED_X, pattern); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Drops a backup with the specified name. |