releasing/cbrtools/perl/RemoteSite/NetDrive/MultiVolumeExport.pm
author marvin shi <marvin.shi@nokia.com>
Wed, 17 Nov 2010 14:05:07 +0800
changeset 691 9eeecb73a5d4
parent 602 3145852acc89
permissions -rw-r--r--
fix ou1cimx1#651819
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
602
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     1
# Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     2
# All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     3
# This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     4
# under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     5
# which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     7
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     8
# Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     9
# Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    10
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    11
# Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    12
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    13
# Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    14
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    15
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    16
# Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    17
# RemoteSite::NetDrive::MultiVolumeExport.pm
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    18
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    19
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    20
package RemoteSite::NetDrive::MultiVolumeExport;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    21
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    22
use strict;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    23
use File::Copy;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
use File::Basename;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
use RemoteSite;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
use RemoteSite::NetDrive;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
use vars qw(@ISA);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    29
@ISA=("RemoteSite::NetDrive");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    31
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
# Constants,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
use constant KLogDirName => '\sent_log';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
# Initialization
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    41
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    43
sub Initialize {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
  my %args = @_;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
  $self->{maxExportVolumeSize} = $args{max_export_volume_size};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
  $self->SUPER::Initialize(@_);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
  $self->Connect();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
  $self->InitNextExportVolume();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
# Public (from RemoteSite)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
sub SendFile {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
  my $localFile = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
  my $remoteFile = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
  unless ($localFile and $remoteFile) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
    $self->HandleError("Incorrect args passed to ".ref($self)."::SendFile");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
  unless (-e $localFile) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
    $self->HandleError("Local file $localFile does not exist");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
  my $fileSize = Utils::FileSize($localFile);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
  if ($fileSize > $self->{maxExportVolumeSize}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
    die "Error: \"$localFile\" is larger than the maximum export volume size ($self->{maxExportVolumeSize})\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
  $self->{currentExportVolumeSize} += $fileSize;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
  if ($self->{currentExportVolumeSize} > $self->{maxExportVolumeSize}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
    $self->InitNextExportVolume();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
    $self->{currentExportVolumeSize} = $fileSize;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
  $self->SUPER::SendFile($localFile, Utils::ConcatenateDirNames($self->CurrentExportVolumeName(), $remoteFile));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
  $self->WriteIndexEntry($remoteFile);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
sub GetFile {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
  $self->HandleError("Function 'GetFile' not supported by ".ref($self)."\n");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
sub FileExists {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
  my $remoteFile = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
  unless (defined $remoteFile) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
    return 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
  $self->Connect();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
  $remoteFile = Utils::ConcatenateDirNames($self->LogDir(), $remoteFile);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
  return (-e $remoteFile);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
sub DirList {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
  $self->HandleError("Function 'DirList' not supported by ".ref($self)."\n");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
sub MakeDir {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   105
  $self->HandleError("Function 'MakeDir' not supported by ".ref($self)."\n");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   106
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   107
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   108
sub FileSize {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   109
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   110
  my $file = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
  my $volume = $self->LookupIndexEntry($file);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
  my $fullName = Utils::ConcatenateDirNames($self->Host(), $self->ExportVolumeName($volume));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
  $fullName = Utils::ConcatenateDirNames($fullName, $file);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   114
  return Utils::FileSize($fullName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   115
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   116
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
sub DeleteFile {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
  $self->HandleError("Function 'DeleteFile' not supported by ".ref($self)."\n");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   122
sub MoveFile {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   123
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   124
  $self->HandleError("Function 'MoveFile' not supported by ".ref($self)."\n");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   125
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   126
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
sub FileModifiedTime {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
  $self->HandleError("Function 'FileModifiedTime' not supported by ".ref($self)."\n");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
# Private.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   136
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   137
sub SetExportVolumePrefix {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   138
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
  $self->{exportVolumePrefex} = time . '__#';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   141
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   142
sub CurrentExportVolumeName {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   143
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   144
  return $self->ExportVolumeName($self->{currentExportVolume});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   145
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   146
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   147
sub ExportVolumeName {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   148
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   149
  my $volume = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   150
  my $name = "$self->{exportVolumePrefex}$volume";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   151
  Utils::TidyFileName(\$name);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   152
  return $name;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   153
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   154
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   155
sub LookupIndexEntry {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   156
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   157
  my $file = lc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   158
  Utils::TidyFileName(\$file);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   159
  if (exists $self->{index}->{$file}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   160
    return $self->{index}->{$file};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   161
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   162
  return undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   163
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   164
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   165
sub WriteIndexEntry {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   166
  # Index entries keep track of which volume of a set a particular release may be found in.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   167
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   168
  my $file = lc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   169
  Utils::TidyFileName(\$file);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   170
  $self->WriteLogEntry($file);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   171
  $self->{index}->{$file} = $self->{currentExportVolume};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   172
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   173
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   174
sub WriteLogEntry {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   175
  # Log entries keep track of what has been sent. KLogDirName should not be deleted between exports.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   176
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   177
  my $file = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   178
  $file = Utils::ConcatenateDirNames($self->LogDir(), $file);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   179
  Utils::MakeDir(dirname($file));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   180
  $self->WriteLogReadMe();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   181
  open (LOG, ">$file") or die "Error: Unable to write log entry \"$file\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   182
  close (LOG);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   183
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   184
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   185
sub WriteLogReadMe {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   186
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   187
  my $readMe = Utils::ConcatenateDirNames($self->LogDir(), 'readme.txt');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   188
  unless (-e $readMe) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   189
    open (README, ">$readMe") or die "Error: Couldn't open \"$readMe\" for writing: $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   190
    print README "This directory contains a log automatically written by the LPD Release Tools as a result of one
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   191
or more exports being performed to a remote site of type 'multi-volume'. It's purpose is to keep track of which
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   192
component releases have already been exported, so they don't get sent again. If you delete this directory, on next
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   193
export, all component releases will need to be sent.";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   194
    close (README);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   195
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   196
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   197
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   198
sub ExternaliseIndex {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   199
  # The index will later be interalised by MultiVolumeExport.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   200
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   201
  for (my $i = 0; $i <= $self->{currentExportVolume}; ++$i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   202
    my $dir = Utils::ConcatenateDirNames($self->Host(), $self->ExportVolumeName($i));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   203
    Utils::MakeDir($dir);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   204
    open (INDEX, ">$dir/index") or die "Error: Couldn't open \"$dir/index\" for writing: $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   205
    foreach my $file (sort keys %{$self->{index}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   206
      print INDEX "$file\t$self->{index}->{$file}\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   207
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   208
    close (INDEX);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   209
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   210
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   211
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   212
sub InitNextExportVolume {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   213
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   214
  $self->{currentExportVolumeSize} = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   215
  if (exists $self->{currentExportVolume}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   216
    ++$self->{currentExportVolume};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   217
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   218
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   219
    $self->{currentExportVolume} = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   220
    $self->SetExportVolumePrefix();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   221
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   222
  my $exportVol = Utils::ConcatenateDirNames($self->Host(), $self->CurrentExportVolumeName());
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   223
  Utils::MakeDir($exportVol);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   224
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   225
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   226
sub LogDir {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   227
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   228
  return Utils::ConcatenateDirNames($self->Host(), KLogDirName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   229
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   230
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   231
sub DESTROY {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   232
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   233
  if ($self->{currentExportVolume} == 0 and not exists $self->{index}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   234
    # Nothing was exported, so cleanup.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   235
    my $dir = Utils::ConcatenateDirNames($self->Host(), $self->CurrentExportVolumeName());
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   236
    rmdir ($dir) or die "Error: Couldn't remove directory \"$dir\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   237
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   238
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   239
    $self->ExternaliseIndex();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   240
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   241
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   242
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   243
1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   244
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   245
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   246
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   247
RemoteSite::NetDrive::MultiVolumeExport.pm - Export encyrpted releases to multiple fixed size volumes
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   248
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   249
=head1 DESCRIPTION
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   250
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   251
The purpose of this remote site module is to allow releases to be exported to directories to be stored on removable media such as writable CD ROMs. It is derived from C<RemoteSite::NetDrive> since a lot of the basic file manipulation is identical.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   252
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   253
The maximum size of each export volume can be specified using the C<IniData> keyword C<max_export_volume_size>. This is used to determine when to start a new volume. At the end of the export process a set of uniquely named directories (the export volumes) will have been created in C<host> directory (specified using the C<IniData> keyword C<remote_host>). There will also be a directory called F<sent_log>, which should be retain between exports so the tools can work out which release have already been exported. Once the export volumes have been archived, they may be deleted.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   254
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   255
=head1 INTERFACE
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   256
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   257
=head2 New
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   258
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   259
Passed an argument list in the form of hash key value pairs. The supported arguments are...
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   260
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   261
  host                   => $host_address_string
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   262
  max_export_volume_size => $max_export_volume_size_integer
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   263
  verbose                => $verbosity_integer
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   264
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   265
Returns a reference to a C<RemoteSite::NetDrive::MultiVolumeExport> object.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   266
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   267
=head2 SendFile
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   268
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   269
Passed a local and a remote file name. Checks the file will fit in the current volume, if not creates a new volume. Logs the file and then differs to C<RemoteSite::NetDrive> to perform the copy.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   270
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   271
=head2 GetFile
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   272
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   273
Not suppored, since this module may only be used for exporting.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   274
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   275
=head2 FileExists
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   276
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   277
Passed a filename (with full path). Checks the F<sent_log> to see is this has already been exported. Returns true if it has, false otherwise.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   278
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   279
=head1 KNOWN BUGS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   280
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   281
None
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   282
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   283
=head1 COPYRIGHT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   284
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   285
 Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   286
 All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   287
 This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   288
 under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   289
 which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   290
 at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   291
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   292
 Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   293
 Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   294
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   295
 Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   296
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   297
 Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   298
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   299
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   300
=cut