rucker / dotfiles-manager

A script to compile your dotfiles!
MIT License
8 stars 0 forks source link

Failure on first run when input file does not exist in output dir #42

Closed rickucker-wk closed 6 years ago

rickucker-wk commented 6 years ago

Scenario: New system. Input file tmux.conf is supplied. A .tmux.conf does not exist in the output dir. dfm.py crashes with the following output:

Traceback (most recent call last):
  File "/home/rick/dotfiles-manager/dotfilesmanager/dfm.py", line 213, in <module>
    main()
  File "/home/rick/dotfiles-manager/dotfilesmanager/dfm.py", line 208, in main
    _process_dotfiles(all_dotfiles_dict)
  File "/home/rick/dotfiles-manager/dotfilesmanager/dfm.py", line 174, in _process_dotfiles
    _process_dotfile(dotfile, all_dotfiles_dict[dotfile])
  File "/home/rick/dotfiles-manager/dotfilesmanager/dfm.py", line 168, in _process_dotfile
    join(env.OUTPUT_DIR, dotfile))
  File "/home/rick/dotfiles-manager/dotfilesmanager/ioutils.py", line 107, in create_symlink
    existing_target = os.readlink(source)
FileNotFoundError: [Errno 2] No such file or directory: '/home/rick/.tmux.conf'

Analysis: ioutils.create_symlink assumes that the target output file either A) exists and is a regular file or B) exists and is a symlink. No logic exists to handle the scenario where the target output file hasn't been created yet.