imjp94 / gd-plug

Minimal plugin manager for Godot
MIT License
213 stars 15 forks source link

Files outside `addons/` are attemping to be downloaded by default. #34

Closed Jack-023 closed 2 months ago

Jack-023 commented 2 months ago

When I run godot --headless -s plug.gd install, gdplug is attempting to download files outside the addons/ directory of various repos when I am not including the "include" setting, and when I am attempting to manually set it to "addons/". I have changed the default plugged directory to res://addons/gd-plug/.plugged as mentioned in other issues but otherwise my gd-plug setup is pretty basic. Here are some examples of the behavior I am seeing.

# res://plug.gd
func _plugging() -> void:
    # attempts to overwrite `res://.git/*`, `res://.gitignore`, `res://icon.svg`, etc.
    plug("heygleeson/godot-ldtk-importer") 

    # attempts to overwrite the same files as above
    plug("godot-extended-libraries/godot-antialiased-line2d", {"include": ["addons"]})

    # this one correctly installs only files in the path provided
    plug("kenyoni-software/godot-addons", {"dev": true, "include": ["addons/icon_explorer"]}) 

Fortunately it runs in safe mode by default I am just getting spammed with warnings but with --force passed it breaks the project repo since all the git files get replaced.

imjp94 commented 2 months ago

It only happens with #33

And it is caused by directory_copy_recursively() just blindly including any path with occurrence of "addons"(which works well if .plugged are not installed in res://addons). So for case of #33, every files will be included, since the addons are installed under res://addons.

Jack-023 commented 2 months ago

Is it a bug in the way the paths are being constructed? I am finding that function a bit difficult to grok so I don't really understand where the problem is being introduced. If I understand correctly, the include option accepts the paths in the plugin repo that should be copied to the projects' res://addons directory.

Are you saying that the path filters in includes are being applied to the project root, rather than the addon's root?

imjp94 commented 2 months ago

It is because directory_copy_recursively() always handling absolute path, for example, res://addons/gd-plug/.plugged/godot-ldtk-importer/.git. Since #33 move all plugins to addons directory, so the check for addons/ is always true, which means all files will be included.

Jack-023 commented 2 months ago

I have updated the directory_copy_recursively() function in #33 to use the full path of the include/exclude directories which seems to have fixed the issue.