preserve permissions when compiling templates
fix missing staging dirs issue