Add default file name for export command (#3248)

This commit is contained in:
OmegaWeaponDev 2022-01-01 02:32:24 +10:30 committed by GitHub
parent 664cad21a9
commit ae93c9768b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 19 additions and 2 deletions

View File

@ -241,6 +241,7 @@ watch-files: true
# below.
# => rabbitmq Uses RabbitMQ pub-sub to push changes. Your server connection info must be
# configured below.
# => custom Uses a messaging service provided using the LuckPerms API.
# => auto Attempts to automatically setup a messaging service using redis or sql.
messaging-service: auto

View File

@ -239,6 +239,7 @@ watch-files: true
# the RedisBungee plugin installed.
# => rabbitmq Uses RabbitMQ pub-sub to push changes. Your server connection info must be
# configured below.
# => custom Uses a messaging service provided using the LuckPerms API.
# => auto Attempts to automatically setup a messaging service using redis or sql.
messaging-service: auto

View File

@ -38,13 +38,19 @@ import me.lucko.luckperms.common.util.Predicates;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.atomic.AtomicBoolean;
public class ExportCommand extends SingleCommand {
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm")
.withZone(ZoneId.systemDefault());
private final AtomicBoolean running = new AtomicBoolean(false);
public ExportCommand() {
super(CommandSpec.EXPORT, "Export", CommandPermission.EXPORT, Predicates.notInRange(1, 2));
super(CommandSpec.EXPORT, "Export", CommandPermission.EXPORT, Predicates.alwaysFalse());
}
@Override
@ -68,7 +74,12 @@ public class ExportCommand extends SingleCommand {
exporter = new Exporter.WebUpload(plugin, sender, includeUsers, includeGroups, label);
} else {
Path dataDirectory = plugin.getBootstrap().getDataDirectory();
Path path = dataDirectory.resolve(args.get(0) + ".json.gz");
Path path;
if (args.isEmpty()) {
path = dataDirectory.resolve("luckperms-" + DATE_FORMAT.format(Instant.now()) + ".json.gz");
} else {
path = dataDirectory.resolve(args.get(0) + ".json.gz");
}
if (!path.getParent().equals(dataDirectory)) {
Message.FILE_NOT_WITHIN_DIRECTORY.send(sender, path.toString());

View File

@ -244,6 +244,7 @@ watch-files = true
# below.
# => rabbitmq Uses RabbitMQ pub-sub to push changes. Your server connection info must be
# configured below.
# => custom Uses a messaging service provided using the LuckPerms API.
# => auto Attempts to automatically setup a messaging service using redis or sql.
messaging-service = "auto"

View File

@ -236,6 +236,7 @@ watch-files: true
# below.
# => rabbitmq Uses RabbitMQ pub-sub to push changes. Your server connection info must be
# configured below.
# => custom Uses a messaging service provided using the LuckPerms API.
# => auto Attempts to automatically setup a messaging service using redis or sql.
messaging-service: auto

View File

@ -244,6 +244,7 @@ watch-files = true
# below.
# => rabbitmq Uses RabbitMQ pub-sub to push changes. Your server connection info must be
# configured below.
# => custom Uses a messaging service provided using the LuckPerms API.
# => auto Attempts to automatically setup a messaging service using redis or sql.
messaging-service = "auto"

View File

@ -230,6 +230,7 @@ watch-files: true
# configured below.
# => rabbitmq Uses RabbitMQ pub-sub to push changes. Your server connection info must be
# configured below.
# => custom Uses a messaging service provided using the LuckPerms API.
# => auto Attempts to automatically setup a messaging service using redis or sql.
messaging-service: auto