CC: Tweaked

CC: Tweaked

42M Downloads

Unable to mount file

LemADEC opened this issue ยท 11 comments

commented
  • Minecraft version 1.12.2
  • CC: Tweaked version 1.80pr1.12

My WarpDrive mod attach a startup file to autoboot the computer when attached to certain blocks.
With CC-Tweaked, it appears file attachment is no longer supported:

[18:54:20] [ComputerCraft-Computer-Runner-0/ERROR] [computercraft]: Could not load mount from mod jar
java.nio.file.NotDirectoryException: assets/warpdrive/lua.ComputerCraft/common/updater
>       at com.sun.nio.zipfs.ZipDirectoryStream.<init>(ZipDirectoryStream.java:73) ~[zipfs.jar:1.8.0_191]
>       at com.sun.nio.zipfs.ZipPath.newDirectoryStream(ZipPath.java:651) ~[zipfs.jar:1.8.0_191]
>       at com.sun.nio.zipfs.ZipFileSystemProvider.newDirectoryStream(ZipFileSystemProvider.java:262) ~[zipfs.jar:1.8.0_191]
>       at java.nio.file.Files.newDirectoryStream(Files.java:457) ~[?:1.8.0_191]
>       at java.nio.file.Files.list(Files.java:3451) ~[?:1.8.0_191]
>       at dan200.computercraft.core.filesystem.FileSystemMount.<init>(FileSystemMount.java:29) ~[FileSystemMount.class:?]
>       at dan200.computercraft.ComputerCraft.createResourceMount(ComputerCraft.java:929) [ComputerCraft.class:?]
>       at sun.reflect.GeneratedMethodAccessor44.invoke(Unknown Source) ~[?:?]
>       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_191]
>       at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_191]
>       at dan200.computercraft.api.ComputerCraftAPI.createResourceMount(ComputerCraftAPI.java:152) [ComputerCraftAPI.class:?]
>       at cr0s.warpdrive.block.TileEntityAbstractInterfaced.attach(TileEntityAbstractInterfaced.java:389) [TileEntityAbstractInterfaced.class:?]
>       at pl.asie.computronics.api.multiperipheral.WrappedMultiPeripheral.attach(WrappedMultiPeripheral.java:43) [WrappedMultiPeripheral.class:?]
>       at pl.asie.computronics.cc.multiperipheral.MultiPeripheral.attach(MultiPeripheral.java:107) [MultiPeripheral.class:?]
>       at dan200.computercraft.core.apis.PeripheralAPI$PeripheralWrapper.attach(PeripheralAPI.java:84) [PeripheralAPI$PeripheralWrapper.class:?]
>       at dan200.computercraft.core.apis.PeripheralAPI.startup(PeripheralAPI.java:336) [PeripheralAPI.class:?]
>       at dan200.computercraft.core.computer.Computer.initLua(Computer.java:741) [Computer.class:?]
>       at dan200.computercraft.core.computer.Computer.access$1400(Computer.java:33) [Computer.class:?]
>       at dan200.computercraft.core.computer.Computer$1.execute(Computer.java:845) [Computer$1.class:?]
>       at dan200.computercraft.core.computer.ComputerThread$TaskRunner.run(ComputerThread.java:284) [ComputerThread$TaskRunner.class:?]
>       at java.lang.Thread.run(Thread.java:748) [?:1.8.0_191]
[18:54:20] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:attach:396]: java.lang.NullPointerException
[18:54:20] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:attach:396]:     at dan200.computercraft.core.filesystem.FileSystem.mount(FileSystem.java:345)
[18:54:20] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:attach:396]:     at dan200.computercraft.core.apis.ComputerAccess.mount(ComputerAccess.java:60)
[18:54:20] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:attach:396]:     at dan200.computercraft.core.apis.PeripheralAPI$PeripheralWrapper.mount(PeripheralAPI.java:131)
[18:54:20] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:attach:396]:     at dan200.computercraft.core.apis.ComputerAccess.mount(ComputerAccess.java:39)
[18:54:20] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:attach:396]:     at cr0s.warpdrive.block.TileEntityAbstractInterfaced.attach(TileEntityAbstractInterfaced.java:389)
[18:54:20] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:attach:396]:     at pl.asie.computronics.api.multiperipheral.WrappedMultiPeripheral.attach(WrappedMultiPeripheral.java:43)
[18:54:20] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:attach:396]:     at pl.asie.computronics.cc.multiperipheral.MultiPeripheral.attach(MultiPeripheral.java:107)
[18:54:20] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:attach:396]:     at dan200.computercraft.core.apis.PeripheralAPI$PeripheralWrapper.attach(PeripheralAPI.java:84)
[18:54:20] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:attach:396]:     at dan200.computercraft.core.apis.PeripheralAPI.startup(PeripheralAPI.java:336)
[18:54:20] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:attach:396]:     at dan200.computercraft.core.computer.Computer.initLua(Computer.java:741)
[18:54:20] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:attach:396]:     at dan200.computercraft.core.computer.Computer.access$1400(Computer.java:33)
[18:54:20] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:attach:396]:     at dan200.computercraft.core.computer.Computer$1.execute(Computer.java:845)
[18:54:20] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:attach:396]:     at dan200.computercraft.core.computer.ComputerThread$TaskRunner.run(ComputerThread.java:284)
[18:54:20] [ComputerCraft-Computer-Runner-0/INFO] [STDERR]: [cr0s.warpdrive.block.TileEntityAbstractInterfaced:attach:396]:     at java.lang.Thread.run(Thread.java:748)

Any reasons for this change? can we restore that feature from the original mod?

commented

Can you post the code you're using to mount the directory?

commented

Sorry about that. I recently rewrote the filesystem handling with the aim of providing a few new features (namely file seeking). I thought I'd caught most of the issues by now, but it looks like I hadn't covered the case where one mounts a single file (rather than the usual directory).

Anyway, this should all be fixed now.

commented

Thanks! Now, let's wait for Curse approval of the new release :)

commented

Here are the related attach & detach methods:

@Override
@Optional.Method(modid = "computercraft")
public void attach(@Nonnull final IComputerAccess computer) {
	final int id = computer.getID();
	connectedComputers.put(id, computer);
	if (CC_hasResource && WarpDriveConfig.G_LUA_SCRIPTS != WarpDriveConfig.LUA_SCRIPTS_NONE) {
		try {
			final String modid = WarpDrive.MODID.toLowerCase();
			final String folderPeripheral = peripheralName.replace(modid, modid + "/");
			computer.mount("/" + modid           , ComputerCraftAPI.createResourceMount(WarpDrive.class, modid, "lua.ComputerCraft/common"));
			computer.mount("/" + folderPeripheral, ComputerCraftAPI.createResourceMount(WarpDrive.class, modid, "lua.ComputerCraft/" + peripheralName));
			computer.mount("/warpupdater"        , ComputerCraftAPI.createResourceMount(WarpDrive.class, modid, "lua.ComputerCraft/common/updater"));
			if (WarpDriveConfig.G_LUA_SCRIPTS == WarpDriveConfig.LUA_SCRIPTS_ALL) {
				for (final String script : CC_scripts) {
					computer.mount("/" + script, ComputerCraftAPI.createResourceMount(WarpDrive.class, modid, "lua.ComputerCraft/" + peripheralName + "/" + script));
				}
			}
		} catch (final Exception exception) {
			exception.printStackTrace();
			WarpDrive.logger.error(String.format("Failed to mount ComputerCraft scripts for %s %s, isFirstTick %s",
			                                     peripheralName,
			                                     Commons.format(world, pos),
			                                     isFirstTick()));
		}
	}
}

@Override
@Optional.Method(modid = "computercraft")
public void detach(@Nonnull final IComputerAccess computer) {
	final int id = computer.getID();
	connectedComputers.remove(id);
}
commented

Here's the result on ShipCore block with Computeacube-1.80pr1+v1.3 or ComputerCraft:
image

Here's the result on same block with CC: Tweaked 1.80pr1.12:
image

commented

Issue is reproduced in dev, SSP and SMP.
Issue is not reproduced with cc-tweaked-1.80pr1.8.

commented

When can we get an updated version on Curse with that fix?

commented

The plan is to release once #98 is merged. It's currently "in testing" (we're running it on a server with a bunch of CC users), so we'll see if any bugs emerge in the next few days.

My computer is currently in a shop, as it's a little busted up, which means I can't give an exact estimate, but hopefully end of this week or beginning of next.

commented

HTTP is too much risk, so it's always disabled on our public servers. Hopefully, we can get some bandwidth and URL restriction system for it in the future.

commented

Thanks for the quick answer, hope your comp gets fixed soon :)

commented

Hopefully, we can get some bandwidth and URL restriction system for it in the future.

There's been an ip blacklist/whitelist for a while now. The PR adds a very small number of limits (max concurrent requests, max download/upload size). Have a look at #33 for some more info, and if you've any comments, do add them to the issue!

That said, I've never really seen any deliberate abuse of http. CC:T has a pretty good system for monitoring its usage (https://squiddev.cc/2018/05/15/cc-track.html), so we're able to find any potential issues quite quickly.