mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 06:50:12 +01:00
Throw during plugin update folder process on failed rename/delete (#11784)
This commit is contained in:
parent
62d4130bba
commit
bd4c235c2f
1 changed files with 17 additions and 7 deletions
|
@ -9,7 +9,6 @@ import io.papermc.paper.plugin.provider.type.PluginFileType;
|
||||||
import org.bukkit.plugin.InvalidPluginException;
|
import org.bukkit.plugin.InvalidPluginException;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.FileVisitResult;
|
import java.nio.file.FileVisitResult;
|
||||||
import java.nio.file.FileVisitor;
|
import java.nio.file.FileVisitor;
|
||||||
|
@ -99,7 +98,7 @@ public class FileProviderSource implements ProviderSource<Path, Path> {
|
||||||
/**
|
/**
|
||||||
* Replaces a plugin with a plugin of the same plugin name in the update folder.
|
* Replaces a plugin with a plugin of the same plugin name in the update folder.
|
||||||
*
|
*
|
||||||
* @param file
|
* @param file The plugin jar file to look for updates for.
|
||||||
*/
|
*/
|
||||||
private Path checkUpdate(Path file) throws InvalidPluginException {
|
private Path checkUpdate(Path file) throws InvalidPluginException {
|
||||||
PluginInitializerManager pluginSystem = PluginInitializerManager.instance();
|
PluginInitializerManager pluginSystem = PluginInitializerManager.instance();
|
||||||
|
@ -121,11 +120,22 @@ public class FileProviderSource implements ProviderSource<Path, Path> {
|
||||||
throw new RuntimeException("Could not copy '" + updateLocation + "' to '" + file + "' in update plugin process", exception);
|
throw new RuntimeException("Could not copy '" + updateLocation + "' to '" + file + "' in update plugin process", exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Idk what this is about, TODO
|
// Rename the plugin file to the update file's name.
|
||||||
File newName = new File(file.toFile().getParentFile(), updateLocation.toFile().getName());
|
final Path renamedFile = file.resolveSibling(updateLocation.getFileName());
|
||||||
file.toFile().renameTo(newName);
|
try {
|
||||||
updateLocation.toFile().delete();
|
Files.move(file, renamedFile, StandardCopyOption.REPLACE_EXISTING);
|
||||||
return newName.toPath();
|
} catch (IOException exception) {
|
||||||
|
throw new RuntimeException("Could not rename '" + file + "' to '" + renamedFile + "' in update plugin process", exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete the file from the update folder now that it's copied over successfully
|
||||||
|
try {
|
||||||
|
Files.delete(updateLocation);
|
||||||
|
} catch (IOException exception) {
|
||||||
|
throw new RuntimeException("Could not delete '" + updateLocation + "' from update folder in update plugin process", exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
return renamedFile;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new InvalidPluginException(e);
|
throw new InvalidPluginException(e);
|
||||||
|
|
Loading…
Reference in a new issue