Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision d22f89a3

Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt

  • ID d22f89a3ae2c24858c53e35d2ae97a862b9fc711
  • Vorgänger 114e10d6
  • Nachfolger f5b999c9

Kosmetik/Refactoring

Unterschiede anzeigen:

SL/Common.pm
595 595
}
596 596

  
597 597
sub copy_file_to_webdav_folder {
598
  $main::lxdebug->enter_sub();
598
  $::lxdebug->enter_sub();
599 599

  
600 600
  my ($form) = @_;
601 601
  my ($last_mod_time, $latest_file_name, $complete_path);
602 602

  
603 603
  # checks
604 604
  foreach my $item (qw(tmpdir tmpfile type)){
605
    if (!$form->{$item}){
606
      $main::lxdebug->message(0, 'Missing parameter');
607
      $main::form->error($main::locale->text("Missing parameter for webdav file copy"));
608
    }
605
    next if $form->{$item};
606
    $::lxdebug->message(LXDebug::WARN(), 'Missing parameter');
607
    $::form->error($::locale->text("Missing parameter for webdav file copy"));
609 608
  }
610 609

  
611 610
  my ($webdav_folder, $document_name) =  get_webdav_folder($form);
612 611

  
613 612
  if (! $webdav_folder){
614
    $main::lxdebug->leave_sub();
615
    $main::form->error($main::locale->text("Cannot check correct webdav folder"));
613
    $::lxdebug->leave_sub();
614
    $::form->error($::locale->text("Cannot check correct webdav folder"));
616 615
    return undef;
617 616
  }
618 617

  
......
623 622
  while ( defined( my $file = readdir( $dh ) ) ) {
624 623
    my $path = File::Spec->catfile( $complete_path, $file );
625 624
    next if -d $path; # skip directories, or anything else you like
626
    ( $newest_name, $newest_time ) = ( $file, -M _ )
627
        if( ! defined $newest_time or -M $path < $newest_time );
628
    }
629
  $latest_file_name = $complete_path .'/' . $newest_name;
630
  my $filesize = stat($latest_file_name)->size;
625
    ( $newest_name, $newest_time ) = ( $file, -M _ ) if( ! defined $newest_time or -M $path < $newest_time );
626
  }
631 627

  
632
  my ($ext) = $form->{tmpfile} =~ /(\.[^.]+)$/;
633
  my $current_file = join('/', $form->{tmpdir}, $form->{tmpfile});
628
  closedir $dh;
629

  
630
  $latest_file_name    = $complete_path .'/' . $newest_name;
631
  my $filesize         = stat($latest_file_name)->size;
632

  
633
  my ($ext)            = $form->{tmpfile} =~ /(\.[^.]+)$/;
634
  my $current_file     = join('/', $form->{tmpdir}, $form->{tmpfile});
634 635
  my $current_filesize = stat($current_file)->size;
636

  
635 637
  if ($current_filesize == $filesize) {
636
    $main::lxdebug->leave_sub();
638
    $::lxdebug->leave_sub();
637 639
    return;
638 640
  }
639 641

  
640
  my $timestamp = get_current_formatted_time();
641
  my $myfilename = $form->generate_attachment_filename();
642
  $myfilename =~ s/\./$timestamp\./;
642
  my $timestamp  =  get_current_formatted_time();
643
  my $myfilename =  $form->generate_attachment_filename();
644
  $myfilename    =~ s/\./$timestamp\./;
643 645

  
644 646
  if (!copy(join('/', $form->{tmpdir}, $form->{tmpfile}), join('/', $form->{cwd}, $webdav_folder, $myfilename))) {
645
    my $j = join('/', $form->{tmpdir}, $form->{tmpfile});
646
    my $k = join('/', $form->{cwd},  $webdav_folder);
647
    $main::lxdebug->message(0, "Copy file from $j to $k failed");
648
    $main::form->error($main::locale->text("Copy file from #1 to #2 failed", $j, $k));
647
    my $from = join('/', $form->{tmpdir}, $form->{tmpfile});
648
    my $to   = join('/', $form->{cwd},    $webdav_folder);
649
    $::lxdebug->message(LXDebug::WARN(), "Copy file from $from to $to failed");
650
    $::form->error($::locale->text("Copy file from #1 to #2 failed", $from, $to));
649 651
  }
650 652

  
651
  $main::lxdebug->leave_sub();
653
  $::lxdebug->leave_sub();
652 654
}
653 655
sub get_current_formatted_time {
654 656
  $main::lxdebug->enter_sub();

Auch abrufbar als: Unified diff