Skip to content

Commit 2d0c38e

Browse files
authored
fix (#1767)
1 parent e196400 commit 2d0c38e

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

tensorflow_io/core/filesystems/http/http_filesystem.cc

+7-2
Original file line numberDiff line numberDiff line change
@@ -782,8 +782,13 @@ static bool IsDirectory(const TF_Filesystem* filesystem, const char* path,
782782
return false;
783783
}
784784

785-
TF_SetStatus(status, TF_OK, "");
786-
return stats.is_directory;
785+
if (stats.is_directory) {
786+
TF_SetStatus(status, TF_OK, "");
787+
return true;
788+
}
789+
790+
TF_SetStatus(status, TF_FAILED_PRECONDITION, "not a directory");
791+
return false;
787792
}
788793

789794
static int GetChildren(const TF_Filesystem* filesystem, const char* path,

tests/test_http.py

+13
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,18 @@ def test_gfile_tell(local_content, remote_filename):
106106
assert remote_gfile.tell() == 100
107107

108108

109+
@pytest.mark.skipif(
110+
sys.platform in ("darwin", "win32"), reason="macOS/Windows fails now"
111+
)
112+
def test_gfile_isdir(remote_filename):
113+
"""Test case for isdir()"""
114+
115+
# A valid http link is not a dir.
116+
assert not tf.io.gfile.isdir(remote_filename)
117+
# An invalid http link is not a dir either.
118+
assert not tf.io.gfile.isdir("https://not-a-valid-domain/tfio-test")
119+
120+
121+
109122
if __name__ == "__main__":
110123
tf.test.main()

0 commit comments

Comments
 (0)