$source = \OC_Share_Backend_File::getSource($target)

Should not be inside the if, same reason as above