cache: only assert on flags when dealing with EMPTYPATH
Reported by: syzbot+bd48ee0843206a09e6b8@syzkaller.appspotmail.com
Fixes: 7dd419cabc6bb9e0 ("cache: add empty path support")
(cherry picked from commit 1045352f150346ba422b3a3ce6344fc694bc3aa4)