Skip to content

Commit cdcb92a

Browse files
committed
check if backup build is newer than runtime build
1 parent 0d34a4d commit cdcb92a

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

setup.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ def list2cmdline(cmd_list):
2929
root_dir = Path(__file__).parent
3030
src_dir = root_dir / "src"
3131
package_dir = src_dir / name
32-
js_runtime_build = package_dir / "client" / "build"
3332

3433

3534
# -----------------------------------------------------------------------------
@@ -143,8 +142,6 @@ def run(self):
143142
log.error(traceback.format_exc())
144143
raise
145144
else:
146-
if js_runtime_build.exists():
147-
shutil.rmtree(js_runtime_build)
148145
log.info("Successfully installed Javascript")
149146
super().run()
150147

src/idom/client/_private.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22
import re
33
import shutil
4+
from os.path import getmtime
45
from pathlib import Path
56
from typing import Dict, Set, Tuple, cast
67

@@ -15,6 +16,15 @@
1516
IDOM_CLIENT_IMPORT_SOURCE_URL_INFIX = "/_snowpack/pkg"
1617

1718

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+
23+
if not IDOM_CLIENT_BUILD_DIR.current.exists():
24+
# populate the runtime build directory if it doesn't exist
25+
shutil.copytree(BACKUP_BUILD_DIR, IDOM_CLIENT_BUILD_DIR.current, symlinks=True)
26+
27+
1828
def get_user_packages_file(app_dir: Path) -> Path:
1929
return app_dir / "packages" / "idom-app-react" / "src" / "user-packages.js"
2030

@@ -25,10 +35,6 @@ def web_modules_dir() -> Path:
2535
)
2636

2737

28-
if not IDOM_CLIENT_BUILD_DIR.current.exists(): # pragma: no cover
29-
shutil.copytree(BACKUP_BUILD_DIR, IDOM_CLIENT_BUILD_DIR.current, symlinks=True)
30-
31-
3238
def restore_build_dir_from_backup() -> None:
3339
target = IDOM_CLIENT_BUILD_DIR.current
3440
if target.exists():

0 commit comments

Comments
 (0)