* checkin with 3.2.0beta0 release header
[BackupPC.git] / lib / BackupPC / Storage / Text.pm
index e1d31cc..c3f5348 100644 (file)
@@ -12,7 +12,7 @@
 #   Craig Barratt  <cbarratt@users.sourceforge.net>
 #
 # COPYRIGHT
-#   Copyright (C) 2004  Craig Barratt
+#   Copyright (C) 2004-2007  Craig Barratt
 #
 #   This program is free software; you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
 #
 #========================================================================
 #
-# Version 3.0.0beta2, released 18 Nov 2006.
+# Version 3.2.0beta0, released 5 April 2009.
 #
 # See http://backuppc.sourceforge.net.
 #
@@ -84,6 +84,18 @@ sub BackupInfoRead
         close(BK_INFO);
     }
     close(LOCK);
+    #
+    # Default the version field.  Prior to 3.0.0 the xferMethod
+    # field is empty, so we use that to figure out the version.
+    #
+    for ( my $i = 0 ; $i < @Backups ; $i++ ) {
+        next if ( $Backups[$i]{version} ne "" );
+        if ( $Backups[$i]{xferMethod} eq "" ) {
+            $Backups[$i]{version} = "2.1.2";
+        } else {
+            $Backups[$i]{version} = "3.0.0";
+        }
+    }
     return @Backups;
 }
 
@@ -202,7 +214,10 @@ sub TextFileWrite
 
     (my $dir = $file) =~ s{(.+)/(.+)}{$1};
 
-    mkpath($dir, 0, 0775) if ( !-d $dir );
+    if ( !-d $dir ) {
+        eval { mkpath($dir, 0, 0775) };
+        return "TextFileWrite: can't create directory $dir" if ( $@ );
+    }
     if ( open(FD, ">", "$file.new") ) {
        binmode(FD);
         print FD $contents;
@@ -279,6 +294,7 @@ sub ConfigDataRead
         }
         %$conf = ( %$conf, %Conf );
     }
+
     #
     # Promote BackupFilesOnly and BackupFilesExclude to hashes
     #