Skip to content

Commit

Permalink
fix (#1767)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-zpeng authored Feb 6, 2023
1 parent e196400 commit 2d0c38e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tensorflow_io/core/filesystems/http/http_filesystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -782,8 +782,13 @@ static bool IsDirectory(const TF_Filesystem* filesystem, const char* path,
return false;
}

TF_SetStatus(status, TF_OK, "");
return stats.is_directory;
if (stats.is_directory) {
TF_SetStatus(status, TF_OK, "");
return true;
}

TF_SetStatus(status, TF_FAILED_PRECONDITION, "not a directory");
return false;
}

static int GetChildren(const TF_Filesystem* filesystem, const char* path,
Expand Down
13 changes: 13 additions & 0 deletions tests/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,18 @@ def test_gfile_tell(local_content, remote_filename):
assert remote_gfile.tell() == 100


@pytest.mark.skipif(
sys.platform in ("darwin", "win32"), reason="macOS/Windows fails now"
)
def test_gfile_isdir(remote_filename):
"""Test case for isdir()"""

# A valid http link is not a dir.
assert not tf.io.gfile.isdir(remote_filename)
# An invalid http link is not a dir either.
assert not tf.io.gfile.isdir("https://not-a-valid-domain/tfio-test")



if __name__ == "__main__":
tf.test.main()

0 comments on commit 2d0c38e

Please sign in to comment.