make sure that source is not a directory

Also fix wrong variable name in logging messages.

Change-Id: Ic5b03714b258859a0eb4a4004b13857ee2b1ae5d
Merge "make sure that source is not a directory"