Merge AUTHOR and CONTRIBUTORS into a single AUTHORS section
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader / Base.pm
index 3cd33f1..2567744 100644 (file)
@@ -29,7 +29,7 @@ use List::Util qw/all any none/;
 use File::Temp 'tempfile';
 use namespace::clean;
 
-our $VERSION = '0.07042';
+our $VERSION = '0.07043';
 
 __PACKAGE__->mk_group_ro_accessors('simple', qw/
                                 schema
@@ -2187,7 +2187,7 @@ sub _write_classfile {
       $self->omit_timestamp ? undef : POSIX::strftime('%Y-%m-%d %H:%M:%S', localtime)
     );
 
-    open(my $fh, '>:encoding(UTF-8)', $filename)
+    open(my $fh, '>:raw:encoding(UTF-8)', $filename)
         or croak "Cannot open '$filename' for writing: $!";
 
     # Write the top half and its MD5 sum
@@ -2236,12 +2236,12 @@ sub _parse_generated_file {
     my $mark_re =
         qr{^(# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:)([A-Za-z0-9/+]{22})\r?\n};
 
-    my ($md5, $ts, $ver, $gen);
+    my ($real_md5, $ts, $ver, $gen);
     local $_;
     while(<$fh>) {
         if(/$mark_re/) {
             my $pre_md5 = $1;
-            $md5 = $2;
+            my $mark_md5 = $2;
 
             # Pull out the version and timestamp from the line above
             ($ver, $ts) = $gen =~ m/^# Created by DBIx::Class::Schema::Loader( v[\d.]+)?( @ [\d-]+ [\d:]+)?\r?\Z/m;
@@ -2249,8 +2249,9 @@ sub _parse_generated_file {
             $ts =~ s/^ @ // if $ts;
 
             $gen .= $pre_md5;
+            $real_md5 = Digest::MD5::md5_base64(encode 'UTF-8', $gen);
             croak "Checksum mismatch in '$fn', the auto-generated part of the file has been modified outside of this loader.  Aborting.\nIf you want to overwrite these modifications, set the 'overwrite_modifications' loader option.\n"
-                if !$self->overwrite_modifications && Digest::MD5::md5_base64(encode 'UTF-8', $gen) ne $md5;
+                if !$self->overwrite_modifications && $real_md5 ne $mark_md5;
 
             last;
         }
@@ -2260,14 +2261,14 @@ sub _parse_generated_file {
     }
 
     my $custom = do { local $/; <$fh> }
-        if $md5;
+        if $real_md5;
 
     $custom ||= '';
     $custom =~ s/$CRLF|$LF/\n/g;
 
     close $fh;
 
-    return ($gen, $md5, $ver, $ts, $custom);
+    return ($gen, $real_md5, $ver, $ts, $custom);
 }
 
 sub _use {
@@ -3201,9 +3202,9 @@ You can also control the renaming with the L</rel_collision_map> option.
 
 L<DBIx::Class::Schema::Loader>, L<dbicdump>
 
-=head1 AUTHOR
+=head1 AUTHORS
 
-See L<DBIx::Class::Schema::Loader/AUTHOR> and L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
+See L<DBIx::Class::Schema::Loader/AUTHORS>.
 
 =head1 LICENSE