[Change] Added some DataSync Output to the verbose logging (#41)
This commit is contained in:
parent
5c10c01bd7
commit
b03c314ecf
5 changed files with 59 additions and 34 deletions
|
@ -5,6 +5,7 @@ import org.betterx.bclib.api.v2.dataexchange.handler.DataExchange;
|
||||||
import org.betterx.bclib.api.v2.dataexchange.handler.autosync.AutoSync;
|
import org.betterx.bclib.api.v2.dataexchange.handler.autosync.AutoSync;
|
||||||
import org.betterx.bclib.api.v2.dataexchange.handler.autosync.AutoSyncID;
|
import org.betterx.bclib.api.v2.dataexchange.handler.autosync.AutoSyncID;
|
||||||
import org.betterx.bclib.config.Config;
|
import org.betterx.bclib.config.Config;
|
||||||
|
import org.betterx.bclib.config.Configs;
|
||||||
import org.betterx.worlds.together.util.ModUtil;
|
import org.betterx.worlds.together.util.ModUtil;
|
||||||
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
@ -55,7 +56,8 @@ public class DataExchangeAPI extends DataExchange {
|
||||||
if (ModUtil.getModInfo(modID, false) != null && !"0.0.0".equals(ModUtil.getModVersion(modID))) {
|
if (ModUtil.getModInfo(modID, false) != null && !"0.0.0".equals(ModUtil.getModVersion(modID))) {
|
||||||
registerMod(modID);
|
registerMod(modID);
|
||||||
} else {
|
} else {
|
||||||
BCLib.LOGGER.info("Mod Dependency '" + modID + "' not found. This is probably OK.");
|
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||||
|
BCLib.LOGGER.info("Mod Dependency '" + modID + "' not found. This is probably OK.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,8 +129,9 @@ public class HelloClient extends DataHandler.FromServer {
|
||||||
modID));
|
modID));
|
||||||
buf.writeBoolean(canDownload);
|
buf.writeBoolean(canDownload);
|
||||||
|
|
||||||
BCLib.LOGGER.info(" - Listing Mod " + modID + " v" + ver + " (size: " + PathUtil.humanReadableFileSize(
|
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||||
size) + ", download=" + canDownload + ")");
|
BCLib.LOGGER.info(" - Listing Mod " + modID + " v" + ver + " (size: " + PathUtil.humanReadableFileSize(
|
||||||
|
size) + ", download=" + canDownload + ")");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BCLib.LOGGER.info("Server will not list Mods.");
|
BCLib.LOGGER.info("Server will not list Mods.");
|
||||||
|
@ -149,7 +150,8 @@ public class HelloClient extends DataHandler.FromServer {
|
||||||
buf.writeInt(existingAutoSyncFiles.size());
|
buf.writeInt(existingAutoSyncFiles.size());
|
||||||
for (AutoFileSyncEntry entry : existingAutoSyncFiles) {
|
for (AutoFileSyncEntry entry : existingAutoSyncFiles) {
|
||||||
entry.serialize(buf);
|
entry.serialize(buf);
|
||||||
BCLib.LOGGER.info(" - Offering " + (entry.isConfigFile() ? "Config " : "File ") + entry);
|
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||||
|
BCLib.LOGGER.info(" - Offering " + (entry.isConfigFile() ? "Config " : "File ") + entry);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BCLib.LOGGER.info("Server will neither offer Files nor Configs.");
|
BCLib.LOGGER.info("Server will neither offer Files nor Configs.");
|
||||||
|
@ -159,7 +161,8 @@ public class HelloClient extends DataHandler.FromServer {
|
||||||
if (Configs.SERVER_CONFIG.isOfferingFiles()) {
|
if (Configs.SERVER_CONFIG.isOfferingFiles()) {
|
||||||
buf.writeInt(AutoSync.syncFolderDescriptions.size());
|
buf.writeInt(AutoSync.syncFolderDescriptions.size());
|
||||||
AutoSync.syncFolderDescriptions.forEach(desc -> {
|
AutoSync.syncFolderDescriptions.forEach(desc -> {
|
||||||
BCLib.LOGGER.info(" - Offering Folder " + desc.localFolder + " (allowDelete=" + desc.removeAdditionalFiles + ")");
|
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||||
|
BCLib.LOGGER.info(" - Offering Folder " + desc.localFolder + " (allowDelete=" + desc.removeAdditionalFiles + ")");
|
||||||
desc.serialize(buf);
|
desc.serialize(buf);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -230,20 +233,23 @@ public class HelloClient extends DataHandler.FromServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (autoSynFolders.size() > 0) {
|
if (autoSynFolders.size() > 0) {
|
||||||
BCLib.LOGGER.info("Folders offered by Server:");
|
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||||
|
BCLib.LOGGER.info("Folders offered by Server:");
|
||||||
}
|
}
|
||||||
|
|
||||||
autoSynFolders.forEach(desc -> {
|
autoSynFolders.forEach(desc -> {
|
||||||
//desc contains the fileCache sent from the server, load the local version to get hold of the actual file cache on the client
|
//desc contains the fileCache sent from the server, load the local version to get hold of the actual file cache on the client
|
||||||
SyncFolderDescriptor localDescriptor = AutoSync.getSyncFolderDescriptor(desc.folderID);
|
SyncFolderDescriptor localDescriptor = AutoSync.getSyncFolderDescriptor(desc.folderID);
|
||||||
if (localDescriptor != null) {
|
if (localDescriptor != null) {
|
||||||
BCLib.LOGGER.info(" - " + desc.folderID + " (" + desc.localFolder + ", allowRemove=" + desc.removeAdditionalFiles + ")");
|
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||||
|
BCLib.LOGGER.info(" - " + desc.folderID + " (" + desc.localFolder + ", allowRemove=" + desc.removeAdditionalFiles + ")");
|
||||||
localDescriptor.invalidateCache();
|
localDescriptor.invalidateCache();
|
||||||
|
|
||||||
desc.relativeFilesStream()
|
desc.relativeFilesStream()
|
||||||
.filter(desc::discardChildElements)
|
.filter(desc::discardChildElements)
|
||||||
.forEach(subFile -> {
|
.forEach(subFile -> {
|
||||||
BCLib.LOGGER.warning(" * " + subFile.relPath + " (REJECTED)");
|
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||||
|
BCLib.LOGGER.warning(" * " + subFile.relPath + " (REJECTED)");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -259,7 +265,8 @@ public class HelloClient extends DataHandler.FromServer {
|
||||||
))
|
))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
additionalFiles.forEach(aid -> BCLib.LOGGER.info(" * " + desc.localFolder.relativize(aid.relFile.toPath()) + " (missing on server)"));
|
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||||
|
additionalFiles.forEach(aid -> BCLib.LOGGER.info(" * " + desc.localFolder.relativize(aid.relFile.toPath()) + " (missing on server)"));
|
||||||
filesToRemove.addAll(additionalFiles);
|
filesToRemove.addAll(additionalFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,17 +277,20 @@ public class HelloClient extends DataHandler.FromServer {
|
||||||
if (localSubFile != null) {
|
if (localSubFile != null) {
|
||||||
//the file exists locally, check if the hashes match
|
//the file exists locally, check if the hashes match
|
||||||
if (!localSubFile.hash.equals(subFile.hash)) {
|
if (!localSubFile.hash.equals(subFile.hash)) {
|
||||||
BCLib.LOGGER.info(" * " + subFile.relPath + " (changed)");
|
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||||
|
BCLib.LOGGER.info(" * " + subFile.relPath + " (changed)");
|
||||||
filesToRequest.add(new AutoSyncID.ForDirectFileRequest(
|
filesToRequest.add(new AutoSyncID.ForDirectFileRequest(
|
||||||
desc.folderID,
|
desc.folderID,
|
||||||
new File(subFile.relPath)
|
new File(subFile.relPath)
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
BCLib.LOGGER.info(" * " + subFile.relPath);
|
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||||
|
BCLib.LOGGER.info(" * " + subFile.relPath);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//the file is missing locally
|
//the file is missing locally
|
||||||
BCLib.LOGGER.info(" * " + subFile.relPath + " (missing on client)");
|
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||||
|
BCLib.LOGGER.info(" * " + subFile.relPath + " (missing on client)");
|
||||||
filesToRequest.add(new AutoSyncID.ForDirectFileRequest(
|
filesToRequest.add(new AutoSyncID.ForDirectFileRequest(
|
||||||
desc.folderID,
|
desc.folderID,
|
||||||
new File(subFile.relPath)
|
new File(subFile.relPath)
|
||||||
|
@ -291,7 +301,8 @@ public class HelloClient extends DataHandler.FromServer {
|
||||||
//free some memory
|
//free some memory
|
||||||
localDescriptor.invalidateCache();
|
localDescriptor.invalidateCache();
|
||||||
} else {
|
} else {
|
||||||
BCLib.LOGGER.info(" - " + desc.folderID + " (Failed to find)");
|
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||||
|
BCLib.LOGGER.info(" - " + desc.folderID + " (Failed to find)");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -301,7 +312,8 @@ public class HelloClient extends DataHandler.FromServer {
|
||||||
final boolean debugHashes = Configs.CLIENT_CONFIG.shouldPrintDebugHashes();
|
final boolean debugHashes = Configs.CLIENT_CONFIG.shouldPrintDebugHashes();
|
||||||
|
|
||||||
if (autoSyncedFiles.size() > 0) {
|
if (autoSyncedFiles.size() > 0) {
|
||||||
BCLib.LOGGER.info("Files offered by Server:");
|
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||||
|
BCLib.LOGGER.info("Files offered by Server:");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Handle single sync files
|
//Handle single sync files
|
||||||
|
@ -328,12 +340,13 @@ public class HelloClient extends DataHandler.FromServer {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (Configs.MAIN_CONFIG.verboseLogging()) {
|
||||||
BCLib.LOGGER.info(" - " + e + ": " + actionString);
|
BCLib.LOGGER.info(" - " + e + ": " + actionString);
|
||||||
if (debugHashes) {
|
if (debugHashes) {
|
||||||
BCLib.LOGGER.info(" * " + e.serverHash + " (Server)");
|
BCLib.LOGGER.info(" * " + e.serverHash + " (Server)");
|
||||||
BCLib.LOGGER.info(" * " + e.localMatch.getFileHash() + " (Client)");
|
BCLib.LOGGER.info(" * " + e.localMatch.getFileHash() + " (Client)");
|
||||||
BCLib.LOGGER.info(" * local Content " + (contentWrapper.getRawContent() == null));
|
BCLib.LOGGER.info(" * local Content " + (contentWrapper.getRawContent() == null));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,10 +362,11 @@ public class HelloClient extends DataHandler.FromServer {
|
||||||
final boolean clientOnly = nfo != null && nfo.metadata.getEnvironment() == ModEnvironment.CLIENT;
|
final boolean clientOnly = nfo != null && nfo.metadata.getEnvironment() == ModEnvironment.CLIENT;
|
||||||
final boolean requestMod = !clientOnly && !serverInfo.version.equals(localVersion) && serverInfo.size > 0 && serverInfo.canDownload;
|
final boolean requestMod = !clientOnly && !serverInfo.version.equals(localVersion) && serverInfo.size > 0 && serverInfo.canDownload;
|
||||||
|
|
||||||
BCLib.LOGGER.info(" - " + e.getKey() + " (client=" + localVersion + ", server=" + serverInfo.version + ", size=" + PathUtil.humanReadableFileSize(
|
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||||
serverInfo.size) + (requestMod ? ", requesting" : "") + (serverInfo.canDownload
|
BCLib.LOGGER.info(" - " + e.getKey() + " (client=" + localVersion + ", server=" + serverInfo.version + ", size=" + PathUtil.humanReadableFileSize(
|
||||||
? ""
|
serverInfo.size) + (requestMod ? ", requesting" : "") + (serverInfo.canDownload
|
||||||
: ", not offered") + (clientOnly ? ", client only" : "") + ")");
|
? ""
|
||||||
|
: ", not offered") + (clientOnly ? ", client only" : "") + ")");
|
||||||
if (requestMod) {
|
if (requestMod) {
|
||||||
filesToRequest.add(new AutoSyncID.ForModFileRequest(e.getKey(), serverInfo.version));
|
filesToRequest.add(new AutoSyncID.ForModFileRequest(e.getKey(), serverInfo.version));
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,11 +73,13 @@ public class RequestFiles extends DataHandler.FromClient {
|
||||||
int size = buf.readInt();
|
int size = buf.readInt();
|
||||||
files = new ArrayList<>(size);
|
files = new ArrayList<>(size);
|
||||||
|
|
||||||
BCLib.LOGGER.info("Client requested " + size + " Files:");
|
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||||
|
BCLib.LOGGER.info("Client requested " + size + " Files:");
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
AutoSyncID asid = AutoSyncID.deserializeData(buf);
|
AutoSyncID asid = AutoSyncID.deserializeData(buf);
|
||||||
files.add(asid);
|
files.add(asid);
|
||||||
BCLib.LOGGER.info(" - " + asid);
|
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||||
|
BCLib.LOGGER.info(" - " + asid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -81,10 +81,12 @@ public class SendFiles extends DataHandler.FromServer {
|
||||||
writeString(buf, token);
|
writeString(buf, token);
|
||||||
buf.writeInt(existingFiles.size());
|
buf.writeInt(existingFiles.size());
|
||||||
|
|
||||||
BCLib.LOGGER.info("Sending " + existingFiles.size() + " Files to Client:");
|
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||||
|
BCLib.LOGGER.info("Sending " + existingFiles.size() + " Files to Client:");
|
||||||
for (AutoFileSyncEntry entry : existingFiles) {
|
for (AutoFileSyncEntry entry : existingFiles) {
|
||||||
int length = entry.serializeContent(buf);
|
int length = entry.serializeContent(buf);
|
||||||
BCLib.LOGGER.info(" - " + entry + " (" + PathUtil.humanReadableFileSize(length) + ")");
|
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||||
|
BCLib.LOGGER.info(" - " + entry + " (" + PathUtil.humanReadableFileSize(length) + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +107,8 @@ public class SendFiles extends DataHandler.FromServer {
|
||||||
|
|
||||||
int size = buf.readInt();
|
int size = buf.readInt();
|
||||||
receivedFiles = new ArrayList<>(size);
|
receivedFiles = new ArrayList<>(size);
|
||||||
BCLib.LOGGER.info("Server sent " + size + " Files:");
|
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||||
|
BCLib.LOGGER.info("Server sent " + size + " Files:");
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
Triple<AutoFileSyncEntry, byte[], AutoSyncID> p = AutoFileSyncEntry.deserializeContent(buf);
|
Triple<AutoFileSyncEntry, byte[], AutoSyncID> p = AutoFileSyncEntry.deserializeContent(buf);
|
||||||
if (p.first != null) {
|
if (p.first != null) {
|
||||||
|
@ -122,9 +125,11 @@ public class SendFiles extends DataHandler.FromServer {
|
||||||
} else {
|
} else {
|
||||||
type = "Ignoring ";
|
type = "Ignoring ";
|
||||||
}
|
}
|
||||||
BCLib.LOGGER.info(" - " + type + p.first + " (" + PathUtil.humanReadableFileSize(p.second.length) + ")");
|
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||||
|
BCLib.LOGGER.info(" - " + type + p.first + " (" + PathUtil.humanReadableFileSize(p.second.length) + ")");
|
||||||
} else {
|
} else {
|
||||||
BCLib.LOGGER.error(" - Failed to receive File " + p.third + ", possibly sent from a Mod that is not installed on the client.");
|
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||||
|
BCLib.LOGGER.error(" - Failed to receive File " + p.third + ", possibly sent from a Mod that is not installed on the client.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,9 +131,11 @@ public class SyncFolderDescriptor {
|
||||||
buf.writeBoolean(removeAdditionalFiles);
|
buf.writeBoolean(removeAdditionalFiles);
|
||||||
buf.writeInt(fileCache.size());
|
buf.writeInt(fileCache.size());
|
||||||
fileCache.forEach(fl -> {
|
fileCache.forEach(fl -> {
|
||||||
BCLib.LOGGER.info(" - " + fl.relPath);
|
if (Configs.MAIN_CONFIG.verboseLogging()) {
|
||||||
if (debugHashes) {
|
BCLib.LOGGER.info(" - " + fl.relPath);
|
||||||
BCLib.LOGGER.info(" " + fl.hash);
|
if (debugHashes) {
|
||||||
|
BCLib.LOGGER.info(" " + fl.hash);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fl.serialize(buf);
|
fl.serialize(buf);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue