Changeset 108

Show
Ignore:
Timestamp:
05/13/07 19:07:07 (2 years ago)
Author:
bradfitz
Message:

start of some code to show size actually needed to upload, ahead of time. usually undesirable, so guard with env variable for now... maybe an option later?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/Brackup/Backup.pm

    r107 r108  
    3737    my $n_files      = 0;   # int 
    3838    my $n_kb_done    = 0.0; # num 
     39    my $n_kb_up      = 0.0; # num 
    3940    my $n_files_done = 0;   # int 
    4041    my @files;         # Brackup::File objs 
     
    4849    }); 
    4950 
     51    $self->debug("Number of files: $n_files\n"); 
     52 
     53    # calc needed chunks 
     54    my $n_kb_up_need = 0; 
     55    if ($ENV{CALC_NEEDED}) { 
     56        my $fn = 0; 
     57        foreach my $f (@files) { 
     58            $fn++; 
     59            if ($fn % 100 == 0) { warn "$fn / $n_files ...\n"; } 
     60            foreach my $pc ($f->chunks) { 
     61                if ($target->stored_chunk_from_inventory($pc)) { 
     62                    $pc->forget_chunkref; 
     63                    next; 
     64                } 
     65                $n_kb_up_need += $pc->length / 1024; 
     66                $pc->forget_chunkref; 
     67            } 
     68        } 
     69        warn "kb need to upload = $n_kb_up_need\n"; 
     70    } 
     71    
     72 
    5073    my $chunk_iterator = Brackup::ChunkIterator->new(@files); 
    5174 
     
    108131            $schunk = Brackup::StoredChunk->new($pchunk); 
    109132 
    110             # encrypt it (TODO: make GPGProcessManager method do this) 
     133            # encrypt it 
    111134            if ($gpg_rcpt) { 
    112135                $schunk->set_encrypted_chunkref($gpg_pm->enc_chunkref_of($pchunk));