Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

chore: ignore /var tmp directory in homepage (#1157)

Akshay Agrawal54e8fe40a6f6
diff --git a/marimo/_server/recents.py b/marimo/_server/recents.py
index cf35b67ad7..c648c5d0cc 100644
--- a/marimo/_server/recents.py
+++ b/marimo/_server/recents.py
@@ -1,5 +1,6 @@
# Copyright 2024 Marimo. All rights reserved.
import os
+import pathlib
from dataclasses import dataclass, field
from typing import List
@@ -13,6 +14,15 @@ class RecentFilesState:
files: List[str] = field(default_factory=list)
+_IGNORED_FOLDERS = ("/tmp", "/var")
+
+
+def _is_tmp_file(filename: str) -> bool:
+ return any(
+ filename.startswith(folder_name) for folder_name in _IGNORED_FOLDERS
+ )
+
+
class RecentFilesManager:
MAX_FILES = 10
LOCATION = "recent_files.toml"
@@ -24,7 +34,7 @@ class RecentFilesManager:
if not self.config:
return
- if filename.startswith("/tmp"):
+ if _is_tmp_file(filename):
return
state = self.config.read_toml(
@@ -59,8 +69,11 @@ class RecentFilesManager:
)
files: List[MarimoFile] = []
+ cwd = pathlib.Path.cwd()
for file in state.files:
- # Check for existence of file
+ file_path = pathlib.Path(file)
+ if _is_tmp_file(file) or cwd not in file_path.parents:
+ continue
if not os.path.exists(file):
continue
files.append(