#3370 kojid: don't fail on missing ccache file
Merged by tkopecek. Opened by tkopecek.
tkopecek/koji issue3369  into  master

Download 3370.patch

Related: https://pagure.io/koji/issue/3369

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

Metadata Update from @jobrauer:
- Pull-request tagged with: testing-done

Commit d6da86ef fixes this pull-request

Pull-Request has been merged by tkopecek

This is a "look before you leap" pattern with os.path.exists(). It's better to call your file operations directly, and ignore the exception if the file does not exist.

Python 3.6+ (ie, CentOS 8) has a FileNotFoundError exception that is handy for this:

try:
    if os.path.getsize(options.ccache) == 0:
        os.remove(options.ccache)
except (FileNotFoundError):
    pass

Maybe better. Anyway, it will mask potential "unlink" problem which raises the same exception. It shouldn't happen, but...

Metadata