Skip to content

Commit 7b7bc4c

Browse files
committed
Catch case where no rsync was attempted so no return code exists for the subprocess
1 parent 593bed0 commit 7b7bc4c

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/murfey/client/rsync.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import logging
44
import os
55
import queue
6+
import subprocess
67
import threading
78
import time
89
from enum import Enum
@@ -383,6 +384,7 @@ def parse_stderr(line: str):
383384

384385
rsync_cmd.extend([".", self._remote])
385386

387+
result: subprocess.CompletedProcess | None = None
386388
success = True
387389
if rsync_stdin:
388390
result = procrunner.run(
@@ -394,7 +396,7 @@ def parse_stderr(line: str):
394396
print_stdout=False,
395397
print_stderr=False,
396398
)
397-
success = result.returncode == 0
399+
success = result.returncode == 0 if result else False
398400

399401
if rsync_stdin_remove:
400402
rsync_cmd.insert(-2, "--remove-source-files")
@@ -409,7 +411,7 @@ def parse_stderr(line: str):
409411
)
410412

411413
if success:
412-
success = result.returncode == 0
414+
success = result.returncode == 0 if result else False
413415

414416
self.notify(successful_updates, secondary=True)
415417

@@ -429,8 +431,11 @@ def parse_stderr(line: str):
429431
self.notify(update)
430432
success = False
431433

432-
logger.log(
433-
logging.WARNING if result.returncode else logging.DEBUG,
434-
f"rsync process finished with return code {result.returncode}",
435-
)
434+
if result is None:
435+
logger.error(f"No rsync process ran for files: {files}")
436+
else:
437+
logger.log(
438+
logging.WARNING if result.returncode else logging.DEBUG,
439+
f"rsync process finished with return code {result.returncode}",
440+
)
436441
return success

0 commit comments

Comments
 (0)