Skip to content
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

fix(symlink): Symlinks to folder showing as files #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

7HR4IZ3
Copy link

@7HR4IZ3 7HR4IZ3 commented Jun 4, 2024

Fixed symbolic links showing up as files on Termux, specifically the '~/storage/shared' -> '/storage/emulated/0' symlink on android devices.

Fixed symbolic links showing up as files on Termux, specifically the '~/storage/shared' -> '/storage/emulated/0' symlink on android devices.
const isDirectory = async (filePath) => (await fs.lstat(filePath)).isDirectory();
const isDirectory = async (filePath) => {
return (
(await fs.stat(filePath)).isDirectory() ||
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to check both? does'nt lstat check the target if it's a symbolic link?

The lstat() function shall be equivalent to stat(), except when path refers to a symbolic link. In that case lstat() shall return information about the link, while stat() shall return information about the file the link references.

https://pubs.opengroup.org/onlinepubs/000095399/functions/lstat.html

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, shouldn't we only check for fs.stat? because we're interested in the target of the link?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.. But you still need lstat for a symlink to a directory to show up as directory and not file on other OS. For some reason, fs.lstat doesn't work on the ~/storage/shared symlink in Termux.. Even though it is a symlink to the /storage/emulated/0 directory on Android, NodeJS fs.lstat identifies it as a file but fs.stat identifies it as a directory..

IMG_20240606_173749

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants