Skip to content

Commit

Permalink
PICARD-2754: Handle launche with relative path and without valid cwd
Browse files Browse the repository at this point in the history
If Picard gets called with a relative path but cwd is invalid (e.g.
removed before actual launch) resolving the path lead to a crash.

Handle this error now by the file loading code
  • Loading branch information
phw committed Sep 14, 2023
1 parent 0e9c684 commit 10eafd1
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions picard/tagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -1467,10 +1467,16 @@ def process_picard_args():
args.remote_commands_help = False

args.processable = []
for x in args.FILE_OR_URL:
if not urlparse(x).netloc:
x = os.path.abspath(x)
args.processable.append(f"LOAD {x}")
for path in args.FILE_OR_URL:
if not urlparse(path).netloc:
try:
path = os.path.abspath(path)
except FileNotFoundError:
# os.path.abspath raises if path is relative and cwd doesn't
# exist anymore. Just pass the path as it is and leave
# the error handling to Picard's file loading.
pass
args.processable.append(f"LOAD {path}")

if args.exec:
for e in args.exec:
Expand Down

0 comments on commit 10eafd1

Please sign in to comment.