Olyno / skent

Manage your files and folder with Skript
GNU General Public License v3.0
11 stars 2 forks source link

Directory not being created and causing errors #35

Closed Shykuzo closed 2 years ago

Shykuzo commented 2 years ago

Describe your problem

When downloading a file and indicating that it should be placed in a folder, if the folder does not exist, an error is returned. It would be good to check if the folder exists and if it does not, it is created automatically.

Versions

Skript: 2.5.3 Server: 1.12.2 (Paper) Skent: 2.1.0

Code

download from url {@DOWNLOAD_URL} to file path "plugins/Punishment-Update/Punishment.zip":
    delete file path getString("GLOBAL.PARAMETERS.AUTO_UPDATE.FILE_PATH"):
        unzip all files in file path "plugins/Punishment-Update/Punishment.zip" to dir path getString("GLOBAL.PARAMETERS.AUTO_UPDATE.DESTINATION_PATH"):
            delete file path "plugins/Punishment-Update/Punishment.zip":
                send "&8[&4Punishment&8] &fMise à jour effectuée, passage en &b%{_Version}% &f!" to console

                loop all players where [input has permission getPermission("ALL")]:
                    send "&8[&4Punishment&8] &fUne mise à jour vient d'être effectuée !" to loop-player

                wait 0.5 second

                set {_Path} to getString("GLOBAL.PARAMETERS.AUTO_UPDATE.FILE_PATH")
                replace all "plugins/Skript/scripts/" with "" in {_Path}
                make console execute command "sk reload %{_Path}%"

Error

https://www.toptal.com/developers/hastebin/otinecalaj.md

Olyno commented 2 years ago

Hi 👋🏻 Thanks you for your report. It looks like there is an issue when downloading the file. This is not directly related to the missing file creation, i don't think. I will fix it for the next release.

Shykuzo commented 2 years ago

I think I have explained it wrong. In fact, when the download is done, the ".zip" file is in "plugins/Punishment-Update/" except that this folder "Punishment-Update" does not create itself is because of the errors.

The download and everything works perfectly, it's really during the unzip that it causes a problem.

You should automatically create the folder if it does not exist, to avoid this kind of error ^^

Olyno commented 2 years ago

So if i summarize the issue, when you're trying to unzip the zipped file, you get an error because the destination directory doesn't exist, right?

Shykuzo commented 2 years ago

Yes, that's it

Olyno commented 2 years ago

Hi 👋🏻 Using the new async system of Skent, this problem should be solved. Here is the code i tried:

command test:
    trigger:
        set {_download_link} to "https://github.com/Olyno/skent/archive/refs/tags/3.1.0.zip"
        sync download file from {_download_link} to file path "plugins/abc.zip"
        sync unzip all files from file path "plugins/abc.zip" to dir path "plugins/abc"
        delete file path "plugins/abc.zip" # Note this line could change between now and the release moment. Look at the release to be sure!

Also, i noticed you used this line: replace all "plugins/Skript/scripts/" with "" in {_Path}. You don't need this line, you can use set {_Path} to file name of {_Path} instead.

Feel free to reopen the issue if not fixed after the release.