Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4b17528a

Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt

  • ID 4b17528afa621f6174983f4002f2cf7d9f092357
  • Vorgänger 0614d6da
  • Nachfolger 53c26ac2

Refactoring: weniger Funktionen importieren; Pfade nicht mehrfach joinen

Unterschiede anzeigen:

SL/Common.pm
15 15
use English qw(-no_match_vars);
16 16
use Time::HiRes qw(gettimeofday);
17 17
use Data::Dumper;
18
use File::Copy;
18
use File::Copy ();
19 19
use File::stat;
20 20
use File::Slurp;
21
use File::Spec;
21 22
use POSIX ();
22 23

  
23 24
use SL::DBUtils;
......
617 618
    return undef;
618 619
  }
619 620

  
620
  $complete_path =  join('/', $form->{cwd},  $webdav_folder);
621
  $complete_path =  File::Spec->catfile($form->{cwd},  $webdav_folder);
621 622
  opendir my $dh, $complete_path or die "Could not open $complete_path: $!";
622 623

  
623 624
  my ($newest_name, $newest_time);
......
629 630

  
630 631
  closedir $dh;
631 632

  
632
  $latest_file_name    = $complete_path .'/' . $newest_name;
633
  $latest_file_name    = File::Spec->catfile($complete_path, $newest_name);
633 634
  my $filesize         = stat($latest_file_name)->size;
634 635

  
635 636
  my ($ext)            = $form->{tmpfile} =~ /(\.[^.]+)$/;
636
  my $current_file     = join('/', $form->{tmpdir}, $form->{tmpfile});
637
  my $current_file     = File::Spec->catfile($form->{tmpdir}, $form->{tmpfile});
637 638
  my $current_filesize = -f $current_file ? stat($current_file)->size : 0;
638 639

  
639 640
  if ($current_filesize == $filesize) {
......
641 642
    return;
642 643
  }
643 644

  
644
  my $timestamp  =  get_current_formatted_time();
645
  my $myfilename =  $form->generate_attachment_filename();
646
  $myfilename    =~ s/\./$timestamp\./;
645
  my $timestamp =  get_current_formatted_time();
646
  my $new_file  =  File::Spec->catfile($form->{cwd}, $webdav_folder, $form->generate_attachment_filename());
647
  $new_file     =~ s/\./$timestamp\./;
647 648

  
648
  if (!copy(join('/', $form->{tmpdir}, $form->{tmpfile}), join('/', $form->{cwd}, $webdav_folder, $myfilename))) {
649
    my $from = join('/', $form->{tmpdir}, $form->{tmpfile});
650
    my $to   = join('/', $form->{cwd},    $webdav_folder);
651
    $::lxdebug->message(LXDebug::WARN(), "Copy file from $from to $to failed");
652
    $::form->error($::locale->text("Copy file from #1 to #2 failed", $from, $to));
649
  if (!File::Copy::copy($current_file, $new_file)) {
650
    $::lxdebug->message(LXDebug::WARN(), "Copy file from $current_file to $new_file failed: $ERRNO");
651
    $::form->error($::locale->text("Copy file from #1 to #2 failed: #3", $current_file, $new_file, $ERRNO));
653 652
  }
654 653

  
655 654
  $::lxdebug->leave_sub();

Auch abrufbar als: Unified diff