mailimage2mysql/m2m
changeset 33 49fd54c8c81a
parent 32 27a0248f5f27
child 34 bd1ec89560e0
equal deleted inserted replaced
32:27a0248f5f27 33:49fd54c8c81a
    59 			ext=$(echo "${on##*.}" | tr [A-Z] [a-z])
    59 			ext=$(echo "${on##*.}" | tr [A-Z] [a-z])
    60 			fn="$(date '+%s.%N').$$.$ext"
    60 			fn="$(date '+%s.%N').$$.$ext"
    61 			ts=$(date '+%F %T')
    61 			ts=$(date '+%F %T')
    62 			cat "$f" > $imgfolder/$fn.tmp
    62 			cat "$f" > $imgfolder/$fn.tmp
    63 			mv $imgfolder/$fn.tmp $imgfolder/$fn
    63 			mv $imgfolder/$fn.tmp $imgfolder/$fn
       
    64 			chmod 644 $imgfolder/$fn
    64 			printf "INSERT INTO $imgtable (file_name, orig_name, mime_type, mail_from, mail_date, mail_message_id, ts) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s');\n" "$fn" "$on" "$mt" "$mfrom" "$mdate" "$mmsgid" "$ts" | $mysql_cmd
    65 			printf "INSERT INTO $imgtable (file_name, orig_name, mime_type, mail_from, mail_date, mail_message_id, ts) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s');\n" "$fn" "$on" "$mt" "$mfrom" "$mdate" "$mmsgid" "$ts" | $mysql_cmd
    65 		fi
    66 		fi
    66 	done < <(find $mdir -type f -name "$pat" -print0)
    67 	done < <(find $mdir -type f -name "$pat" -print0)
    67 }
    68 }
    68 
    69