Add flag to exclude users from an export (#961)
This commit is contained in:
parent
194b602fd6
commit
ab8b675bae
@ -79,12 +79,14 @@ public class Exporter implements Runnable {
|
||||
private final LuckPermsPlugin plugin;
|
||||
private final Sender executor;
|
||||
private final Path filePath;
|
||||
private final boolean includeUsers;
|
||||
private final ProgressLogger log;
|
||||
|
||||
public Exporter(LuckPermsPlugin plugin, Sender executor, Path filePath) {
|
||||
public Exporter(LuckPermsPlugin plugin, Sender executor, Path filePath, boolean includeUsers) {
|
||||
this.plugin = plugin;
|
||||
this.executor = executor;
|
||||
this.filePath = filePath;
|
||||
this.includeUsers = includeUsers;
|
||||
|
||||
this.log = new ProgressLogger(null, Message.EXPORT_LOG, Message.EXPORT_LOG_PROGRESS);
|
||||
this.log.addListener(plugin.getConsoleSender());
|
||||
@ -169,7 +171,7 @@ public class Exporter implements Runnable {
|
||||
|
||||
this.log.log("Exported " + tracks.size() + " tracks.");
|
||||
|
||||
|
||||
if (this.includeUsers) {
|
||||
// Users are migrated in separate threads.
|
||||
// This is because there are likely to be a lot of them, and because we can.
|
||||
// It's a big speed improvement, since the database/files are split up and can handle concurrent reads.
|
||||
@ -262,8 +264,10 @@ public class Exporter implements Runnable {
|
||||
}
|
||||
|
||||
executor.shutdown();
|
||||
|
||||
this.log.log("Exported " + userCount.get() + " users.");
|
||||
}
|
||||
|
||||
|
||||
writer.flush();
|
||||
this.log.getListeners().forEach(l -> Message.LOG_EXPORT_SUCCESS.send(l, this.filePath.toFile().getAbsolutePath()));
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class ExportCommand extends SingleCommand {
|
||||
private final AtomicBoolean running = new AtomicBoolean(false);
|
||||
|
||||
public ExportCommand(LocaleManager locale) {
|
||||
super(CommandSpec.EXPORT.localize(locale), "Export", CommandPermission.EXPORT, Predicates.not(1));
|
||||
super(CommandSpec.EXPORT.localize(locale), "Export", CommandPermission.EXPORT, Predicates.notInRange(1, 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -57,6 +57,8 @@ public class ExportCommand extends SingleCommand {
|
||||
}
|
||||
|
||||
Path path = plugin.getBootstrap().getDataDirectory().resolve(args.get(0));
|
||||
boolean includeUsers = !args.remove("--without-users");
|
||||
|
||||
if (Files.exists(path)) {
|
||||
Message.LOG_EXPORT_ALREADY_EXISTS.send(sender, path.toString());
|
||||
return CommandResult.INVALID_ARGS;
|
||||
@ -80,7 +82,7 @@ public class ExportCommand extends SingleCommand {
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
|
||||
Exporter exporter = new Exporter(plugin, sender, path);
|
||||
Exporter exporter = new Exporter(plugin, sender, path, includeUsers);
|
||||
|
||||
// Run the exporter in its own thread.
|
||||
plugin.getBootstrap().getScheduler().doAsync(() -> {
|
||||
|
Loading…
Reference in New Issue
Block a user