Closed chevdor closed 3 years ago
I have no Linux desktop to test, but the correct path sould be /Users/me/Desktop/joplin import1
without \
befor the space.
That would be quite non standard. Space is a special character and should be escaped on all *nix patforms.
If you fancy testing, you may with Docker: docker run --rm -it ubuntu bash
:
root@9f2d782bd248:/tmp# mkdir some\ space
root@9f2d782bd248:/tmp# ll
total 12
drwxrwxrwt 1 root root 4096 Mar 26 19:09 ./
drwxr-xr-x 1 root root 4096 Mar 26 19:09 ../
drwxr-xr-x 2 root root 4096 Mar 26 19:09 'some space'/
root@9f2d782bd248:/tmp# cd some\ space/
root@9f2d782bd248:/tmp/some space#
You may want to use https://nodejs.org/api/path.html#path_path_normalize_path
to normalize the user's entry so all valid path strings such as the example I mentioned work anyway.
I can confirm after testing (and restarting Joplin, which seems to be mandatory), that using a non escaped path works: /Users/me/Desktop/joplin import1
The path.normalize() method normalizes the given path, resolving '..' and '.' segments.
fs.existsSync("/usr/src/app/joplin import"); // => True
fs.existsSync(path.normalize("/usr/src/app/joplin import")); // => True
fs.existsSync("/usr/src/app/joplin\\ import"); // => False
fs.existsSync(path.normalize("/usr/src/app/joplin\\ import")); // => False
I'm still waiting for the file selector as API in Joplin, then you can select the path directly.
fs.existsSync("/usr/src/app/joplin\ import"); // => False
That's because you should not use \\
but \
. Otherwise, you are not making a space but a back slash followed by breaking space... The \
is actually escaping the space.
fs.existsSync("some\ space.txt"); // => true
fs.existsSync("some\\ space.txt"); // => false
fs.existsSync(path.normalize("some space.txt")); // => true
fs.existsSync(path.normalize("some\ space.txt")); // => true
Yes because one \
is an escape caracter in a string, when you want a \
in a string you have to use twice.
When you write test\test
you get test<TAB>est
because this is the tab char.
But you can check it with an input and enter /usr/src/app/joplin\ import
rl.question('Test Path? ', (answer) => {
check = `${answer}`;
fs.existsSync(check); // => False
fs.existsSync(path.normalize(check)); // => False
rl.close();
});
The normalize function don't change anything on the \<space>
Hello,
I could successfully use the plugin with a path without spaces. Using
/Users/me/Desktop/joplin\ import1
however does not seem to trigger the import. it shows no error but nothing happens.