Cleanup: Fix potential NPE in Updater
This commit is contained in:
parent
92a013dd10
commit
385672ecd4
|
@ -393,22 +393,27 @@ public final class Updater {
|
||||||
if (this.pluginFile(dFile.getName())) {
|
if (this.pluginFile(dFile.getName())) {
|
||||||
final File oFile = new File(this.plugin.getDataFolder().getParent(), dFile.getName()); // Get current dir
|
final File oFile = new File(this.plugin.getDataFolder().getParent(), dFile.getName()); // Get current dir
|
||||||
final File[] contents = oFile.listFiles(); // List of existing files in the current dir
|
final File[] contents = oFile.listFiles(); // List of existing files in the current dir
|
||||||
for (final File cFile : dFile.listFiles()) // Loop through all the files in the new dir
|
final File[] newFiles = dFile.listFiles();
|
||||||
{
|
if (newFiles != null) {
|
||||||
boolean found = false;
|
for (final File cFile : newFiles) // Loop through all the files in the new dir
|
||||||
for (final File xFile : contents) // Loop through contents to see if it exists
|
|
||||||
{
|
{
|
||||||
if (xFile.getName().equals(cFile.getName())) {
|
boolean found = false;
|
||||||
found = true;
|
if (contents != null) {
|
||||||
break;
|
for (final File xFile : contents) // Loop through contents to see if it exists
|
||||||
|
{
|
||||||
|
if (xFile.getName().equals(cFile.getName())) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
// Move the new file into the current dir
|
||||||
|
cFile.renameTo(new File(oFile.getCanonicalFile() + File.separator + cFile.getName()));
|
||||||
|
} else {
|
||||||
|
// This file already exists, so we don't need it anymore.
|
||||||
|
cFile.delete();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!found) {
|
|
||||||
// Move the new file into the current dir
|
|
||||||
cFile.renameTo(new File(oFile.getCanonicalFile() + File.separator + cFile.getName()));
|
|
||||||
} else {
|
|
||||||
// This file already exists, so we don't need it anymore.
|
|
||||||
cFile.delete();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue