forked from ungleich-public/cdist
		
	Merge branch 'file/better-errors' into 'master'
[__file] Better errors analogous to __directory See merge request ungleich-public/cdist!854
This commit is contained in:
		
				commit
				
					
						4b24d886eb
					
				
			
		
					 2 changed files with 48 additions and 32 deletions
				
			
		| 
						 | 
				
			
			@ -31,12 +31,24 @@ if [ "$state_should" = "pre-exists" ]; then
 | 
			
		|||
      exit 1
 | 
			
		||||
   fi
 | 
			
		||||
 | 
			
		||||
   if [ "$type" = "file" ]; then
 | 
			
		||||
      exit 0 # nothing to do
 | 
			
		||||
   else
 | 
			
		||||
      echo "File \"$destination\" does not exist"
 | 
			
		||||
   case $type in
 | 
			
		||||
      file)
 | 
			
		||||
         # nothing to do
 | 
			
		||||
         exit 0
 | 
			
		||||
      ;;
 | 
			
		||||
      none)
 | 
			
		||||
         printf 'File "%s" does not exist\n' "$destination" >&2
 | 
			
		||||
         exit 1
 | 
			
		||||
   fi
 | 
			
		||||
      ;;
 | 
			
		||||
      directory|symlink)
 | 
			
		||||
         printf 'File "%s" exists and is a %s, but should be a regular file\n' "$destination" "$type" >&2
 | 
			
		||||
         exit 1
 | 
			
		||||
      ;;
 | 
			
		||||
      *)
 | 
			
		||||
         printf 'File or directory "%s" is in an unknown state\n' "$destination" >&2
 | 
			
		||||
         exit 1
 | 
			
		||||
      ;;
 | 
			
		||||
   esac
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
upload_file=
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -61,7 +61,7 @@ set_mode() {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
case "$state_should" in
 | 
			
		||||
    present|exists|pre-exists)
 | 
			
		||||
    present|exists)
 | 
			
		||||
        # Note: Mode - needs to happen last as a chown/chgrp can alter mode by
 | 
			
		||||
        #  clearing S_ISUID and S_ISGID bits (see chown(2))
 | 
			
		||||
        for attribute in group owner mode; do
 | 
			
		||||
| 
						 | 
				
			
			@ -83,7 +83,11 @@ case "$state_should" in
 | 
			
		|||
            # set-attributes is created if file is created or uploaded in gencode-local
 | 
			
		||||
            fire_onchange=1
 | 
			
		||||
        fi
 | 
			
		||||
    ;;
 | 
			
		||||
 | 
			
		||||
    pre-exists)
 | 
			
		||||
        # pre-exists should never reach gencode-remote…
 | 
			
		||||
        exit 1
 | 
			
		||||
   ;;
 | 
			
		||||
 | 
			
		||||
    absent)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue