alecgorge / jsonapi

A JSON API for Minecraft: http://forums.bukkit.org/threads/admn-info-jsonapi-v1-3-1-json-http-and-socket-api-for-controlling-a-server-740.14270/
http://mcjsonapi.com
MIT License
232 stars 88 forks source link

File could not be written to! #452

Open HeyAwesomePeople opened 9 years ago

HeyAwesomePeople commented 9 years ago

I'm having this issue where whenever I run the setFileContents command, I get this response:

'message' => string 'plugins/groupmanager/worlds/world/groups.yml could not be written to!' (length=69)

Console: http://hastebin.com/ocadacacep.tex

The file is valid and in that location, and the file is not open anywhere else. What's going on here? I am unable to find anyone with this problem. Thanks

R3d0x5704 commented 9 years ago

CHMOD 777 the file for test

HeyAwesomePeople commented 9 years ago

I'm using Windows, so I do not have any CHMOD commands. Is there a windows equivalent?

electronicboy commented 9 years ago

That could be the issue, Try grabbing a windows file unlocker tool, unlocking the file and trying if that API call works. The error message is caused when an IO exception occurs, a locked file could be the cause of that error.

HeyAwesomePeople commented 9 years ago

With the windows unlocked tool I am using, Unlocker 1.9.2, it says there is no locking handle found on the file. I have also forced ownership of the file to me, still nothing. There was one instance in which the call setFileContents worked, but I am unable to recreate that instance no matter what I try. Would be awesome to have the ability to turn on JsonAPIs debug messages they have put in their code, as we should be able to minimize the problem search area there.

electronicboy commented 9 years ago

Try deleting the file and then re-creating it?

https://github.com/alecgorge/jsonapi/blob/master/src/main/java/com/alecgorge/minecraft/jsonapi/dynamic/APIWrapperMethods.java#L848 is the method which is being called, adding and printing to the console e.getMessage(), I think it is, may help you;

I'm not sure what you're trying to accomplish by re-writing the contents of the groups file, if you're going to be playing around with GM it makes more sense to shove GM into a MySQL DB and interact with it programmatically through a database, you're less likely to run into issues as modifying the groups file in this manner isn't something thats usually done, all it takes is for an admin or somebody to run /manload at the wrong time or a minor mess up with a rewrite and you're in for hell

HeyAwesomePeople commented 9 years ago

I'm simply just trying to edit the groups and permissions of GroupManager via the internet. The way I am doing it now is working fine, and I don't see how it can be broken...? The only way I think it could be broken is if someone was editing groupmanager on the server and someone else was editing groupmanager on the website.

Do you have any ideas on how I could go about this then? The MySQL DB for GM isn't really an easy solution. It would be more work to plugin GM into a database and leave room for more issues.

HeyAwesomePeople commented 9 years ago

It's basically an File Editor. File editors typically just replace the file when edited, correct?(Seems like the easiest way). So if I am going to run into these issues now, how does a File Editor get around them?

HeyAwesomePeople commented 9 years ago

After switching to a linux based platform for testing, I've gotten no errors about this since. But now there's this issue: https://github.com/alecgorge/jsonapi/issues/456