New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add editor.delete_directory()
#8473
Conversation
I created it by looking at the PR #8434 Haven't figured out how to build the editor locally yet, but the code seems simple. Please correct me if something is wrong 🙈. |
editor.delete_directory()
I think it's good if you try to set up the editor so that you can build it. Submitting PRs "in the blind" so to speak is not a good practice :-) What kind of problems did you have when trying to set everything up? |
I've just tested it and it doesn't work:
|
Sorry for your time, yes, that was brave 🫣. Gone to build the editor... |
We have #source-code channel in Discord. Feel free to ask your questions there. We will help you to build the engine (the first step) and the editor. |
No need to build the engine if you're making a change that only affects the editor in isolation. The More info about the |
@matgis oh, I didn't know that. Nice! |
Thanks for the PR! |
@JCash I would feel more justified in asking for a test if our code they based this on had tests. 😅 Personally I think we can add tests later. |
f9dbd58
to
9fbef4e
Compare
Thanks. I built the editor and fixed the code. Updated the commit, now directory deletion works 👍 But still not sure if the exceptions I added will work, or if any other checks are needed. I have not been able to reproduce |
9fbef4e
to
150a8da
Compare
UPDATE:
Now there are only issues of code reuse in |
@astrochili I added a commit with some additional protections against deleting anything below If it looks good to you, perhaps you could cherry-pick it into your PR? |
@matgis Added a cherry-picked commit, looks good? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I'm going to merge it to editor-dev
. Once CI completes, you should get it in the next editor update.
(if (.startsWith dir-path root-path) | ||
(try | ||
(fs/create-path-directories! dir-path) | ||
(vreset! request-sync true) | ||
nil | ||
(catch FileAlreadyExistsException e | ||
(throw (LuaError. (str "File already exists: " (.getMessage e))))) | ||
(throw (LuaError. (str "Directory already exists: " (.getMessage e))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fairly certain the error message should say "file already exists" and not "directory already exists". Directory already existing is not an error and should not throw exception. What should throw exception is if you wanted a directory at a certain path, and it turned out at that path there is a file instead, that's what the error it's about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh really? I was thinking it's just a typo. So how to fix it back, a new PR? 🤔
* Reverted wrong error message renaming #8473 (comment)
Fixes #8472
Technical changes
This changeset adds a new function to editor scripts that allows the user to delete an existing directory. The function expects a resource path, i.e. a /-prefixed path from the root of the project, for example: