Skip to content

Commit cc15245

Browse files
committed
Removing notes to self
1 parent 5aaa249 commit cc15245

File tree

1 file changed

+0
-21
lines changed

1 file changed

+0
-21
lines changed

shiny/ui/_include_helpers.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ def include_js(
8989
if method == "inline":
9090
return tags.script(read_utf8(file_path), **kwargs)
9191

92-
# QUESTION: Do we have access to the session or user at this point? Can write based on that and then give them full perms?
93-
# Where does cleanup happen?! Seems like maybe that needs to be included before we make new folders? Check the date? Tell if active
94-
# session using them?!
95-
9692
include_files = method == "link_files"
9793
path_dest, hash = maybe_copy_files(file_path, include_files)
9894

@@ -219,37 +215,22 @@ def create_include_dependency(
219215
def maybe_copy_files(path: Path | str, include_files: bool) -> tuple[str, str]:
220216
hash = get_hash(path, include_files)
221217

222-
# To avoid unnecessary work when the same file is included multiple times,
223-
# use a directory scoped by a hash of the file.
224-
# We need to make tempdir deterministic if we use the pythong TemporaryDirectory class so we can still tell if the hash has changed
225-
# We want the temp dir unique to the process, hash should be the only thing that is dynamic based on the file contents.
226-
# Cleanup done using __del__?
227-
# Also make perms so that others can read it
228-
# Double check clean-up based on process ending
229218
tmpdir = os.path.join(tempfile.gettempdir(), "shiny_include_files", hash)
230219
path_dest = os.path.join(tmpdir, os.path.basename(path))
231220
print("tmpdir, path_dest: ", tmpdir, path_dest)
232221

233222
# Since the hash/tmpdir should represent all the files in the path's directory,
234223
# we can simply return here
235224
if os.path.exists(path_dest):
236-
print("path exists: ", path_dest, hash)
237225
return path_dest, hash
238226

239227
# Otherwise, make sure we have a clean slate
240-
# We only hit this if tempdir/ exists but not the file (i.e. style.css)
241228
if os.path.exists(tmpdir):
242-
print("clean the slate, tmpdir", tmpdir)
243229
shutil.rmtree(tmpdir)
244230

245231
if include_files:
246-
print("include files true")
247-
# TODO: Switch this to tempfile.mkdtmp? This will scope perms to the userID
248-
# QUESTION what is the user id? The system user? How does that work in Connect?
249232
shutil.copytree(os.path.dirname(path), tmpdir)
250233
else:
251-
print("include files false")
252-
# This should probably use the temp file syntax
253234
os.makedirs(tmpdir, exist_ok=True)
254235
shutil.copy(path, path_dest)
255236

@@ -259,8 +240,6 @@ def maybe_copy_files(path: Path | str, include_files: bool) -> tuple[str, str]:
259240
def get_hash(path: Path | str, include_files: bool) -> str:
260241
if include_files:
261242
dir = os.path.dirname(path)
262-
# This is recursively listing everything in the dir and making that part of the hash even though we're not pulling it over
263-
# Ex. we make a hash, we copy over one file, then we jsut don't keep going
264243
files = glob.iglob(os.path.join(dir, "**"), recursive=True)
265244
key = "\n".join([get_file_key(x) for x in files])
266245
else:

0 commit comments

Comments
 (0)