1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved Why can't I delete .phar files ?

Discussion in 'Development' started by Oioi, Oct 6, 2017.

  1. Oioi

    Oioi Spider

    Messages:
    11
    I'm working on a plugin delete script. But there is another way to test this without any script.
    This video demonstrates what I mean.

    https://streamable.com/pzc6u

    First I was unable to rename a phar. Move it to an empty plugins folder made it being able to rename. But in the old plugins folder there was a plugin that is loaded but able to rename (at the end of the video).

    PHP:
    #$file instanceof DirectoryIterator
    unlink($file->getPathname());
    Code:
    Disabling AutoInv v1.0.0
    [Server thread/INFO]: An unknown error occurred while attempting to perform this command
    [Server thread/CRITICAL]: Unhandled exception executing command 'fcau remove AutoInv' in fcau: unlink(AutoInv.phar): Resource temporarily unavailable
    [Server thread/CRITICAL]: ErrorException: "unlink(AutoInv.phar): Resource temporarily unavailable" (EXCEPTION)
    
     
  2. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    I'm not sure either but i'll make a wild guest, It's probably that the server has already loaded the phar and i can see the it being disabled but who knows what a server can do and what it can mock.
     
  3. Oioi

    Oioi Spider

    Messages:
    11
    I've looked into PluginManager and can't find the unloadPlugin() function or anything similar. Do you have any idea what to do for temporary solution?
     
  4. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    I don't think there's any other way than "unlink()" in PHP.
     
  5. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    You are going to get into all kinds of trouble renaming, deleting, or moving phar files while the server is running. For a better solution, take a look at Sheep:
    https://github.com/KnownUnown/Sheep
     
    iiFlamiinBlaze and Oioi like this.
  6. Oioi

    Oioi Spider

    Messages:
    11
  7. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    The author loaded the plugin into an array and then unset it. I don't know how to explain more in depth but that's the main concept.
     
    Oioi likes this.
  8. Oioi

    Oioi Spider

    Messages:
    11
    So Sheep doesn't
    and it decided to just put the contents into the phar. And it works for me, as long as the plugin has been disabled before putting in new contents.
     
  9. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    Oioi and jasonwynn10 like this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.