X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FLib.pm;h=fe31429c9ae43aa43372021b1bba9adc9b28f41a;hp=cf99f4b0307202fe5a59ec50280d69a457a2f53b;hb=72b87b178ae8dcc10f1ae0f441d13e30d5f1ecf1;hpb=5729095faa3ef12dc5d4f02538c3650ac81912ef diff --git a/lib/BackupPC/Lib.pm b/lib/BackupPC/Lib.pm index cf99f4b..fe31429 100644 --- a/lib/BackupPC/Lib.pm +++ b/lib/BackupPC/Lib.pm @@ -70,6 +70,9 @@ sub new num startTime endTime result errorMsg nFiles size tarCreateErrs xferErrs )], + ArchiveFields => [qw( + num startTime endTime result errorMsg + )], }, $class; $bpc->{BinDir} .= "/bin"; $bpc->{LibDir} .= "/lib"; @@ -255,6 +258,51 @@ sub RestoreInfoWrite close(LOCK); } +sub ArchiveInfoRead +{ + my($bpc, $host) = @_; + local(*ARCHIVE_INFO, *LOCK); + my(@Archives); + + flock(LOCK, LOCK_EX) if open(LOCK, "$bpc->{TopDir}/pc/$host/LOCK"); + if ( open(ARCHIVE_INFO, "$bpc->{TopDir}/pc/$host/archives") ) { + binmode(ARCHIVE_INFO); + while ( ) { + s/[\n\r]+//; + next if ( !/^(\d+.*)/ ); + $_ = $1; + @{$Archives[@Archives]}{@{$bpc->{ArchiveFields}}} = split(/\t/); + } + close(ARCHIVE_INFO); + } + close(LOCK); + return @Archives; +} + +sub ArchiveInfoWrite +{ + my($bpc, $host, @Archives) = @_; + local(*ARCHIVE_INFO, *LOCK); + my($i); + + flock(LOCK, LOCK_EX) if open(LOCK, "$bpc->{TopDir}/pc/$host/LOCK"); + unlink("$bpc->{TopDir}/pc/$host/archives.old") + if ( -f "$bpc->{TopDir}/pc/$host/archives.old" ); + rename("$bpc->{TopDir}/pc/$host/archives", + "$bpc->{TopDir}/pc/$host/archives.old") + if ( -f "$bpc->{TopDir}/pc/$host/archives" ); + if ( open(ARCHIVE_INFO, ">$bpc->{TopDir}/pc/$host/archives") ) { + binmode(ARCHIVE_INFO); + for ( $i = 0 ; $i < @Archives ; $i++ ) { + my %b = %{$Archives[$i]}; + printf(ARCHIVE_INFO "%s\n", + join("\t", @b{@{$bpc->{ArchiveFields}}})); + } + close(ARCHIVE_INFO); + } + close(LOCK); +} + sub ConfigRead { my($bpc, $host) = @_; @@ -692,7 +740,8 @@ sub MakeFileLink return -2 if ( !defined($rawFile = $bpc->MD52Path($d, $compress)) ); $rawFile .= "_$i" if ( $i >= 0 ); if ( -f $rawFile ) { - if ( !compare($name, $rawFile) ) { + if ( (stat(_))[3] < $bpc->{Conf}{HardLinkMax} + && !compare($name, $rawFile) ) { unlink($name); return -3 if ( !link($rawFile, $name) ); return 1;