View | Details | Raw Unified | Return to bug 38115
Collapse All | Expand All

(-)a/misc/export_records.pl (-10 / +39 lines)
Lines 132-137 if ($destination_server_id) { Link Here
132
        unless $file_transport;
132
        unless $file_transport;
133
}
133
}
134
134
135
# Validate flag combinations
136
if ( $delete_local_after_run && !$destination_server_id ) {
137
    pod2usage("--delete_local_after_run requires --destination_server_id to be specified");
138
}
139
135
if ($report_id) {
140
if ($report_id) {
136
141
137
    # Check report exists
142
    # Check report exists
Lines 355-377 if ($deleted_barcodes) { Link Here
355
}
360
}
356
361
357
if ($file_transport) {
362
if ($file_transport) {
358
    $file_transport->connect
359
        or die pod2usage( sprintf( "Unable to connect server (%s)", $destination_server_id ) );
360
363
364
    # Verify the file was created successfully before attempting upload
365
    unless ( -f $filename ) {
366
        die "Error: Output file '$filename' was not created successfully\n";
367
    }
368
369
    # Connect to the transport
370
    unless ( $file_transport->connect ) {
371
        die sprintf( "Error: Unable to connect to file transport server (ID: %s)\n", $destination_server_id );
372
    }
373
374
    # Change to upload directory if specified
361
    my $upload_dir = $file_transport->upload_directory;
375
    my $upload_dir = $file_transport->upload_directory;
362
    if ($upload_dir) {
376
    if ($upload_dir) {
363
        $file_transport->change_directory($upload_dir)
377
        unless ( $file_transport->change_directory($upload_dir) ) {
364
            or die pod2usage(
378
            $file_transport->disconnect;
365
            sprintf( "Unable to change directory on server (%s) to path (%s)", $destination_server_id, $upload_dir ) );
379
            die sprintf(
380
                "Error: Unable to change to upload directory '%s' on server (ID: %s)\n", $upload_dir,
381
                $destination_server_id
382
            );
383
        }
384
    }
385
386
    # Upload the file
387
    unless ( $file_transport->upload_file( $filename, $filename ) ) {
388
        $file_transport->disconnect;
389
        die sprintf( "Error: Unable to upload file '%s' to server (ID: %s)\n", $filename, $destination_server_id );
366
    }
390
    }
367
391
368
    $file_transport->upload_file( $filename, $filename )
392
    # Always disconnect when done
369
        or die pod2usage( sprintf( "Unable to upload file (%s) to server (%s)", $filename, $destination_server_id ) );
393
    $file_transport->disconnect;
394
395
    print STDERR "Successfully uploaded '$filename' to file transport server (ID: $destination_server_id)\n";
370
}
396
}
371
397
372
if ($delete_local_after_run) {
398
if ($delete_local_after_run) {
373
    unlink $filename
399
    if ( -f $filename ) {
374
        or die pod2usage( sprintf( "Unable to delete local file (%s)", $filename ) );
400
        unless ( unlink $filename ) {
401
            die sprintf( "Error: Unable to delete local file '%s': %s\n", $filename, $! );
402
        }
403
        print STDERR "Successfully deleted local file '$filename'\n";
404
    }
375
}
405
}
376
406
377
exit;
407
exit;
378
- 

Return to bug 38115