From 31fa92a83f6dabfe4064084304326f305d6f0702 Mon Sep 17 00:00:00 2001 From: David Ford <2772469+david-ford@users.noreply.github.com> Date: Mon, 29 Aug 2022 12:46:24 -0500 Subject: [PATCH 1/2] Fix case sensitive check to be case insensitive Case sensitivity between os.getcwd and os.realpath can fail due to different drive letter casing. C:\ vs c:\. This change addresses that by normalizing the strings before comparing. --- .gitattributes | 4 ++++ ldm/dream/server.py | 4 ++-- static/dream_web/index.html | 7 ++++--- 3 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000000..61934b80029 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +# Auto normalizes line endings on commit so devs don't need to change local settings. +# Only effects text files and ignores other file types. +# For more info see: https://www.aleksandrhovhannisyan.com/blog/crlf-vs-lf-normalizing-line-endings-in-git/ +* text=auto diff --git a/ldm/dream/server.py b/ldm/dream/server.py index efe3139f74f..bf73b5dca4e 100644 --- a/ldm/dream/server.py +++ b/ldm/dream/server.py @@ -17,8 +17,8 @@ def do_GET(self): self.wfile.write(content.read()) else: path = "." + self.path - cwd = os.getcwd() - is_in_cwd = os.path.commonprefix((os.path.realpath(path), cwd)) == cwd + cwd = os.getcwd().lower() + is_in_cwd = os.path.commonprefix((os.path.realpath(path).lower(), cwd)) == cwd if not (is_in_cwd and os.path.exists(path)): self.send_response(404) return diff --git a/static/dream_web/index.html b/static/dream_web/index.html index 34ee69bad27..4b49d49bc77 100644 --- a/static/dream_web/index.html +++ b/static/dream_web/index.html @@ -1,6 +1,7 @@ - + Stable Diffusion Dream Server + @@ -13,7 +14,7 @@
@@ -70,7 +71,7 @@ From ed38c97ed83233432c9e4fc00b53c9115a5fb177 Mon Sep 17 00:00:00 2001 From: David Ford <2772469+david-ford@users.noreply.github.com> Date: Mon, 29 Aug 2022 16:43:34 -0500 Subject: [PATCH 2/2] Removed unrelated changes and updated based on recommendation Removed the changes to the index.html and .gitattributes for this PR. Will add them in separate PRs. Applied recommended change for resolving the case issue. --- .gitattributes | 4 ---- ldm/dream/server.py | 4 ++-- static/dream_web/index.html | 7 +++---- 3 files changed, 5 insertions(+), 10 deletions(-) delete mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 61934b80029..00000000000 --- a/.gitattributes +++ /dev/null @@ -1,4 +0,0 @@ -# Auto normalizes line endings on commit so devs don't need to change local settings. -# Only effects text files and ignores other file types. -# For more info see: https://www.aleksandrhovhannisyan.com/blog/crlf-vs-lf-normalizing-line-endings-in-git/ -* text=auto diff --git a/ldm/dream/server.py b/ldm/dream/server.py index bf73b5dca4e..db33f6d6a02 100644 --- a/ldm/dream/server.py +++ b/ldm/dream/server.py @@ -17,8 +17,8 @@ def do_GET(self): self.wfile.write(content.read()) else: path = "." + self.path - cwd = os.getcwd().lower() - is_in_cwd = os.path.commonprefix((os.path.realpath(path).lower(), cwd)) == cwd + cwd = os.path.realpath(os.getcwd()) + is_in_cwd = os.path.commonprefix((os.path.realpath(path), cwd)) == cwd if not (is_in_cwd and os.path.exists(path)): self.send_response(404) return diff --git a/static/dream_web/index.html b/static/dream_web/index.html index 4b49d49bc77..34ee69bad27 100644 --- a/static/dream_web/index.html +++ b/static/dream_web/index.html @@ -1,7 +1,6 @@ - + Stable Diffusion Dream Server - @@ -14,7 +13,7 @@
@@ -71,7 +70,7 @@