Skip to content

Commit ba66b0f

Browse files
committed
only check mtime if exists
1 parent cdcb92a commit ba66b0f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/idom/client/_private.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616
IDOM_CLIENT_IMPORT_SOURCE_URL_INFIX = "/_snowpack/pkg"
1717

1818

19-
if getmtime(BACKUP_BUILD_DIR) > getmtime(IDOM_CLIENT_BUILD_DIR.current):
20-
# delete the runtime build if the backup build is newer (i.e. IDOM was re-installed)
21-
shutil.rmtree(IDOM_CLIENT_BUILD_DIR.current)
22-
2319
if not IDOM_CLIENT_BUILD_DIR.current.exists():
2420
# populate the runtime build directory if it doesn't exist
2521
shutil.copytree(BACKUP_BUILD_DIR, IDOM_CLIENT_BUILD_DIR.current, symlinks=True)
22+
elif getmtime(BACKUP_BUILD_DIR) > getmtime(IDOM_CLIENT_BUILD_DIR.current):
23+
# delete the existing runtime build because it's out of date
24+
shutil.rmtree(IDOM_CLIENT_BUILD_DIR.current)
25+
# replace it with the newer backup build (presumable from a fresh install)
26+
shutil.copytree(BACKUP_BUILD_DIR, IDOM_CLIENT_BUILD_DIR.current, symlinks=True)
2627

2728

2829
def get_user_packages_file(app_dir: Path) -> Path:

0 commit comments

Comments
 (0)