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
BREAKING CHANGE: Refactor fs #8792
Conversation
Now the basic refactoring is done and ready for early review. How to Test
Platform Checklist
Operations
|
UPDATE: There won't be more functional and refactoring commits. |
About the E2E CI failure:
The behavior on the master branch is normal, but it is wrong in the pull request. Related code: logseq/src/main/frontend/util.cljc Lines 140 to 144 in de2c1f7
|
89c9514
to
be639e1
Compare
dffe301
to
a62ca64
Compare
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.
@andelf Thanks for taking on this necessary and tricky refactor. I haven't finished reviewing this large PR but figured I'd share my feedback so far
@@ -155,6 +156,7 @@ | |||
|
|||
(defn- get-file-absolute-path | |||
[config path] | |||
(js/console.error "TODO: buggy path fn") |
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.
Can this be removed?
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.
will remove this in the next PR.
(->> (take-last 2 (string/split repo-url #"/")) | ||
(string/join "_"))))) | ||
(do | ||
(js/console.error "BUG: This should be unreachable! get-repo-dir" repo-url) |
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.
If this shouldn't happen, should we also notify sentry so we know this is happening?
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.
This is a notification to devs, not a fatal error. To standardize the use of get-repo-dir
.
@@ -0,0 +1,302 @@ | |||
(ns logseq.common.path |
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 think it's great we're trying to improve file and path handling. However, this is the 3rd major approach to file and path handling after frontend.util/node-path.*
and the npm path library. Without some documentation it's unclear when to use which approach. Could you write some docs on when to use this ns? Some questions that would be helpful to answer in docs:
- Is there a plan to deprecate the other approaches and if so, what is it?
- When to use
filename
vsutil/node-path.basename
? - When to use
file-ext
vsgp-util/path->file-ext
? - When to use
path-join
vsutil/node-path.join
ornode-path/join
? What type of paths should we not use join for? I've seen relative paths likelogseq/config.edn
aren't using it so maybe it's only for full paths? - What platforms do these fns support? For example, is
relative-path
mostly for mobile since it's replacingcapacitor-fs/replacing normalize-file-protocol-path
?
@@ -0,0 +1,27 @@ | |||
(ns logseq.common.path-test |
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.
Could you add tests for more of the main fns? Perhaps some of the deleted tests of capacitor-fs-test
can be reused. I'd be hesitant to use this library going forward if there's little shared understanding of what the expected behavior is. I can help with desktop tests if you'd like
@andelf Added a commit to setup tests and fix minor stuff. Just trying to help on workflow so feel free to change it if you have a preferred setup. Should be able to do QA and finish review tomorrow |
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.
@andelf QAed desktop and browser and it works great except for config issues. I fixed global config issues I was seeing. I see that config editing fails to open in the browser and confirmed this was occurring before my commits. Back to you for that bug and some comments. Can help with desktop tests tomorrow if you'd like
@@ -1,6 +1,6 @@ | |||
(ns frontend.handler.file-sync | |||
"Provides util handler fns for file sync" | |||
(:require ["path" :as path] | |||
(:require ["path" :as node-path] |
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.
Good idea to rename to avoid having conflict aliases. Happy to finish doing these renames in a follow up PR
- basic clj-kondo config and cleanup unused binding - Add some unit tests - Add a basic readme
browserfs integrationassets://
URL percent-encoding handlingmemory://
path