|
23 | 23 | BUILD_INFO_FILE = "xpra/build_info.py"
|
24 | 24 |
|
25 | 25 |
|
26 |
| -def update_properties(props: dict, filename: str) -> None: |
| 26 | +def update_properties(props: dict[str, Any], filename: str) -> None: |
27 | 27 | eprops = get_properties(filename)
|
28 |
| - for key, value in props.items(): |
29 |
| - if value is None: |
30 |
| - continue |
31 |
| - if value not in ("unknown", "") or not props.get(key): |
32 |
| - props[key] = value |
| 28 | + eprops.update(props) |
33 | 29 | save_properties(eprops, filename)
|
34 | 30 |
|
35 | 31 |
|
36 |
| -def save_properties(props: dict, filename: str) -> None: |
| 32 | +def save_properties(props: dict[str, Any], filename: str) -> None: |
37 | 33 | if os.path.exists(filename):
|
38 | 34 | try:
|
39 | 35 | os.unlink(filename)
|
@@ -395,18 +391,14 @@ def record_src_info() -> None:
|
395 | 391 | update_properties(get_vcs_props(), SRC_INFO_FILE)
|
396 | 392 |
|
397 | 393 |
|
398 |
| -def has_src_info() -> bool: |
399 |
| - return os.path.exists(SRC_INFO_FILE) and os.path.isfile(SRC_INFO_FILE) |
400 |
| - |
401 |
| - |
402 |
| -def has_build_info() -> bool: |
403 |
| - return os.path.exists(BUILD_INFO_FILE) and os.path.isfile(BUILD_INFO_FILE) |
| 394 | +def check_file(filename: str) -> bool: |
| 395 | + return os.path.exists(filename) and os.path.isfile(filename) and os.stat(filename).st_size > 0 |
404 | 396 |
|
405 | 397 |
|
406 | 398 | def main(args):
|
407 |
| - if not has_src_info() or "src" in args: |
| 399 | + if not check_file(SRC_INFO_FILE) or "src" in args: |
408 | 400 | record_src_info()
|
409 |
| - if not has_build_info() or "build" in args: |
| 401 | + if not check_file(BUILD_INFO_FILE) or "build" in args: |
410 | 402 | record_build_info()
|
411 | 403 | if "revision" in args:
|
412 | 404 | props = get_vcs_props()
|
|
0 commit comments